Thanks very much.

It would be great if the template doc page (
https://docs.puppet.com/puppet/5.3/lang_template.html) gave more guidance
on epp vs erp, use cases for each and possible gotchas like this.

On Fri, Oct 6, 2017 at 4:17 PM, Henrik Lindberg <henrik.lindb...@puppet.com>
wrote:

> On 06/10/17 11:28, Daniel Urist wrote:
>
>> I've noticed in classes with multiple templates that ERB variables seem
>> to share a single scope. That caught me by surprise-- is that intended
>> behavior?
>>
>>
> Intended or not - that is the behavior, and this is Ruby so it is possible
> to mutate things that should be immutable.
>
> There is great responsibility when writing code in ERB because of the
> generality and power available in Ruby. Suggest using EPP instead where
> problems like this one does not occur.
>
> Best,
> - henrik
>
> Here's a simple test case:
>>
>> class erb_scope_test (
>> )
>> {
>>    $myarr1 = [ 'one' ]
>>    $myarr2 = [ 'two' ]
>>
>>    $str1 = inline_template("<%= @myarr1.concat(@myarr2) %>")
>>    notify { $str1: }
>>
>>    $str2 = inline_template("<%= @myarr1.concat(@myarr2) %>")
>>    notify { $str2: }
>> }
>>
>> Notice: ["one", "two"]
>> Notice: ["one", "two", "two"]
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to puppet-users+unsubscr...@googlegroups.com <mailto:
>> puppet-users+unsubscr...@googlegroups.com>.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/puppet-users/CAEo6%3DKbd8wMO9rvzHMe4W-bo%2BizqLxyAyEf4Th
>> WScOAgpL%2BkdA%40mail.gmail.com <https://groups.google.com/d/m
>> sgid/puppet-users/CAEo6%3DKbd8wMO9rvzHMe4W-bo%2BizqLxyAyEf4T
>> hWScOAgpL%2BkdA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Visit my Blog "Puppet on the Edge"
> http://puppet-on-the-edge.blogspot.se/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/puppet-users/or8vca%242te%241%40blaine.gmane.org.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAEo6%3DKY%2B16i7Nxpaj9yDo%3DsY_YW6WdBfPUVHC0Dw2jBas7JQdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to