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/msgid/puppet-users/CAEo6%3DKbd8wMO9rvzHMe4W-bo%2BizqLxyAyEf4ThWScOAgpL%2BkdA%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-users/CAEo6%3DKbd8wMO9rvzHMe4W-bo%2BizqLxyAyEf4ThWScOAgpL%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/msgid/puppet-users/or8vca%242te%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.