On Monday, February 4, 2013 11:49:24 PM UTC-6, David Kerr wrote: > > > > On Monday, February 4, 2013 9:07:49 PM UTC-8, Aaron Russo wrote: >> >> >> On Mon, Feb 4, 2013 at 7:37 PM, David Kerr <ker...@gmail.com> wrote: >> >>> <% @foo = 0 %> >>> <% Array(bar).each do |flan| -%> >>> value <%= @foo %> >>> <% @foo += 1 %> >>> <% end %> >>> >> >> This code worked for me. I just used an inline template, but otherwise I >> had exactly what you had: >> >> link: https://gist.github.com/arusso23/4712284 >> >> (I'm on 3.0.1 btw) >> >> > > hmm, ok thanks, good to know it SHOULD work =) > > I believe my problem is that i'm using concat and my expectations of how > that works are incorrect. > >
You didn't say what those expectations were, but I'm guessing you hoped the counter would retain its value across multiple evaluations of the template. Perhaps that's why you used a member variable for your counter instead of a local variable. You should expect, however, that every time you invoke the template() or inline_template() function, a new ERB instance will be created to evaluate the given template, so even if you worked around the re-initialization of your counter, I would not expect a continuous sequence across multiple template evaluations. Supposing that you have all the data you want to sequence in one place, one possibility could be to generate your content all in one template. If you don't have it all in one place, on the other hand, and you can't assign sequence numbers manually, then I am skeptical about sequence numbers being useful to you / doing what you want even if you could generate them. If you tell us more about the problem then maybe we'll have better-targeted suggestions. John -- 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 post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.