Issue #6492 has been updated by Ben Hughes. Status changed from Unreviewed to Needs design decision Assignee set to Nigel Kersten
---------------------------------------- Bug #6492: Local ruby variables in templates are not available in "included" templates https://projects.puppetlabs.com/issues/6492 Author: Peter Meier Status: Needs design decision Priority: Normal Assignee: Nigel Kersten Category: file Target version: Affected Puppet version: 2.6.5rc5 Keywords: Branch: Given the following code: <pre> #some_template.erb <%- [:foo, :bar].each do |state| %> <%= scope.function_template('some/other_template.erb') %> <%- end %> # some/other_template.erb <%- if state == :foo %> write something <%- end %> </pre> You will have the error/problem that `state` is not defined. There is a dirty workaround for this problem: <pre> #some_template.erb <%- [:foo, :bar].each do |state| scope.unsetvar('state') scope.setvar('state',state) %> <%= scope.function_template('some/other_template.erb') %> <%- end %> </pre> However, I think there should be either a shortcut to make the variable available in included templates or the variables should be present in the "included" template as local variables. Note that also assigning `state` to an instance variable does not work: <pre> #some_template.erb <%- [:foo, :bar].each do |state| @state = state %> <%= scope.function_template('some/other_template.erb') %> <%- end %> </pre> -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
