I usually just make a big blob at the top that builds my output.

<%

output = []
if @stuff
 output << 'foo'
end

output << 'bar'
-%>
<%= output.join("\n") %>


On Tue, Apr 15, 2014 at 2:38 PM, Joshua Hoblitt <[email protected]> wrote:

> I see the "Non Goals" section at the top of the arm but...
>
> The biggest frustration I have with ERB is when you end up needing
> nested flow control logic.  As example, to walk through a
> hash/array/etc. nested inside some conditional logic.  The result is an
> eye gouging mix of nested <% ... %> and <% end %> tags that are either
> unindented or you have have to salt all the tags with -'s to try and
> properly eat the whitespace.
>
> Here's a snippet from a template I was working on yesterday:
>
> ```
> <% if megaraid_device and megaraid_device != '' and
>      @megaraid_adapters and @megaraid_adapters.to_i > 0 -%>
>     <%- unless @megaraid_physical_drives_sata.nil? -%>
>         <%- @megaraid_physical_drives_sata.split(/,/).sort.each do
> |drive| -%>
> <%= megaraid_device %> -d sat+megaraid,<%= drive.to_i -%>
>             <%- if megaraid_options %><%= ' ' + megaraid_options %><% end
> %>
>         <%- end -%>
>     <%- end -%>
>     <%- unless @megaraid_physical_drives_sas.nil? -%>
>         <%- @megaraid_physical_drives_sas.split(/,/).sort.each do
> |drive| -%>
> <%= megaraid_device %> -d megaraid,<%= drive.to_i -%>
>             <%- if megaraid_options %><%= ' ' + megaraid_options %><% end
> %>
>         <%- end -%>
>     <%- end -%>
> <% end -%>
> ```
>
> It's completely reasonable to argue that some of the boolean logic and
> sanitation (the input variables are mostly facts) could be lifted up
> into the DSL and simplified to boolean flag variables that are passed to
> the template.  Under EPP such flag variables could at least be scoped.
> However, that would not eliminate the nested conditional logic /tag mess.
>
> It would be nice, under some circumstances, to have a function/method to
> "print" from the puppet mode sections of the template similar to this
> functionality for rails:
>
>
> http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-concat
>
> -Josh
>
> --
> On 04/15/2014 11:01 AM, Andy Parker wrote:
> > There hasn't been any discussion on this as far as I can see. The
> > functionality is in the 3.5.0 version that we had to pull, and it will
> also
> > be in 3.5.1 that we should be releasing soon. If anyone has any comments
> > please let us know. The design of this is still open for change until we
> > reach puppet 4, where the new language system will become the default and
> > any more changes to this will become more difficult.
> >
> >
> > On Mon, Mar 17, 2014 at 12:12 PM, Henrik Lindberg <
> > [email protected]> wrote:
> >
> >> In 3.5.0, the ARM-3 Puppet Templates feature is available when using
> >> --parser future.
> >>
> >> The ARM-3 text has been updated to reflect the implementation.
> >>
> >> Since already published Armature documents are difficult to comment on,
> >> the same text is available for comments here:
> https://docs.google.com/a/
> >> puppetlabs.com/document/d/1JzDDvSYD3qgeTr6a3H0Ur8GHNVLep
> >> yJMLid9YHLgYVg/edit#
> >>
> >> If you just want a short introduction, you can read my blog post
> >> about Puppet Templates here: http://puppet-on-the-edge.
> >> blogspot.se/2014/03/templating-with-embedded-puppet.html
> >>
> >> I hope you enjoy the new functionality, and I am looking forward to
> >> feedback if you like the new features EPP templates bring.
> >>
> >> The idea is to make Puppet Templates a standard feature in Puppet 4.0
> >>
> >> Regards
> >> - henrik
> >>
> >> --
> >> 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/lg7hfc%24amu%241%40ger.gmane.org.
> >> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/534D7CBD.5030905%40cpan.org.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
[email protected]

-- This account not approved for unencrypted proprietary information --

-- 
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/CANs%2BFoWCY7LAjFxZ%3Ds8%3DsW5WBLw8BMhJCwmwE9HQ2Ch9NyA6BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to