On 2015-11-09 11:31, Erik Dalén wrote:
You use the range function from stdlib to create an array. For example:
range(1,5).each |$x| {notice($x)}


The same is achieved with an Integer type:

Integer[1,5].each |$x| { notice $x }

It is more efficient than the range function since it does not create an array of all values in the range.

- henrik

On Fri, 11 Sep 2015 at 10:41 Martin Alfke <[email protected]
<mailto:[email protected]>> wrote:

    Hi Michael,

    On 10 Sep 2015, at 17:29, Michael Smith
    <[email protected] <mailto:[email protected]>>
    wrote:

     > Looking at the examples for the 'each' function
    (https://docs.puppetlabs.com/references/latest/function.html#each)
    you can replace 'times' with 'each' and I think it'll work.

    each can be used on arrays. In my case the variable is an integer.
    I want to print stuff $i times into the final file.

     >
     > On Sep 10, 2015, at 4:34 AM, Martin Alfke <[email protected]
    <mailto:[email protected]>> wrote:
     >
     >> Hi,
     >>
     >> is there a way to iterate with the ruby .times function inside
    an EPP template?
     >>
     >> e.g.
     >> <% $i.times |$x| { -%>
     >> i = <%= $x +1 %>
     >> <% } -%>
     >> The code above seems to need a puppet4 function with name “times”.
     >> Result:
     >> Error: Evaluation Error: Unknown function: 'times'.
     >>
     >> When changing to ruby code style another error occurs:
     >> <% $i.times do |$x| -%>
     >> i = <%= $x +1 %>
     >> <% end -%>
     >> Error: Evaluation Error: Error while evaluating a Function Call,
    epp(): Invalid EPP: Syntax error at ‘|'
     >>
     >> thanks,
     >> Martin
     >>
     >> --
     >> You received this message because you are subscribed to the
    Google Groups "Puppet Developers" group.
     >> To unsubscribe from this group and stop receiving emails from
    it, send an email to [email protected]
    <mailto:puppet-dev%[email protected]>.
     >> To view this discussion on the web visit
    
https://groups.google.com/d/msgid/puppet-dev/4F22DF3E-4CD3-410E-B602-BD5B94CE089A%40gmail.com.
     >> For more options, visit https://groups.google.com/d/optout.
     >
     > --
     > You received this message because you are subscribed to the
    Google Groups "Puppet Developers" group.
     > To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:puppet-dev%[email protected]>.
     > To view this discussion on the web visit
    
https://groups.google.com/d/msgid/puppet-dev/3B71678C-05FD-4E4B-B608-EC4A769A2CDB%40puppetlabs.com.
     > For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google
    Groups "Puppet Developers" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:puppet-dev%[email protected]>.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/puppet-dev/238A23C7-A1D5-4E09-830E-A4F49142E43F%40gmail.com.
    For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google
Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CAAAzDLc5utqECijD-Zd%2BAUVTbbHC61hxuO%2BxNNT2ovmbzHApuw%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CAAAzDLc5utqECijD-Zd%2BAUVTbbHC61hxuO%2BxNNT2ovmbzHApuw%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 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/mt1d3l%242nq%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to