Issue #6492 has been updated by Peter Meier. Status changed from Needs design decision to Rejected
> P.S. If templates took parameters (so that you could pass data into them) I > believe that would resolve the use case, but that isn't something we support. > Perhaps this should be a "Feature: function_template should take an optional > hash of values to pass in to the template" or some such? good point. I'll open such a ticket. ---------------------------------------- Bug #6492: Local ruby variables in templates are not available in "included" templates https://projects.puppetlabs.com/issues/6492 Author: Peter Meier Status: Rejected Priority: Normal Assignee: Nigel Kersten Category: file Target version: Affected Puppet version: 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.
