On Tuesday, April 15, 2014 6:28:58 PM UTC-5, Joshua Hoblitt wrote: > > On 04/15/2014 12:28 PM, John Bollinger wrote: > > > > You are complaining about a problem partially of your own making: you > break > > up the Ruby a lot more than you need to do. Obviously you *can* do it > like > > that, but why? > > I find it's difficult to comprehend nested code intermixed with lines > that start with markup tags. > >
Fair enough. Though I can't quite keep myself from suggesting that it's then ERB in general that you dislike. > > Here's an alternative that I like a lot better: > > I think this is arguably worse because it's visually very difficult to > line up the the start and end of code blocks. > > > <% > > if megaraid_device and megaraid_device != '' and > > @megaraid_adapters and @megaraid_adapters.to_i > 0 > > option_str = (megaraid_options ? ' ' + megaraid_options : '') > > unless @megaraid_physical_drives_sata.nil? > > @megaraid_physical_drives_sata.split(/,/).sort.each do |drive| > > -%> > > <%= megaraid_device %> -d sat+megaraid,<%= drive.to_i %><%= option_str > %> > > <% > > end > > end > > unless @megaraid_physical_drives_sas.nil? > > @megaraid_physical_drives_sas.split(/,/).sort.each do |drive| > > -%> > > <%= megaraid_device %> -d megaraid,<%= drive.to_i %><%= option_str %> > > This is still a nightmare to edit [without breaking whitespace/etc.]. > > > <% > > end > > end > > end > > -%> > > This is an illustrative example of the issue I was describing. It's a > "design smell", in my opinion. > > I agree that there's a design smell here. A template such as this one -- mostly Ruby with only a few bits of interspersed template text -- would be better implemented as a custom function. John -- 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/52b1fac1-b4e1-4398-93bc-e96a1e36674d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
