> I'd like to do something like this:
>
> <show-page>
> <% fields = ['rock', 'kind']
> fields << 'channel' if this.channel
> fields << 'episode' if this.episode
> fields << 'parent'] -%>
> <field-list: fields="&fields.join(',')"/>
> </show-page>
>
> Problem is, this produces the dreaded "mixed parameter tags and
> non-parameter tags (did you forget a ':'?) -- at
> app/views/permids/show.dryml:1" error. Surprising since the ERb block
> shouldn't produce any output.
It helps to think of parameter tags as like keyword arguments in Ruby.
e.g.
show_page :field_list => { :fields => fields.join(',') }
From that point of view, what you've written is something like:
show_page (fields = ['rock', 'kind'];
fields << 'channel' if this.channel;
fields << 'episode' if this.episode;
fields << 'parent'])
:field_list => { :fields => fields.join(',') }
Which is obviously wrong
What you would write in Ruby would really be:
fields = ['rock', 'kind']
fields << 'channel' if this.channel
fields << 'episode' if this.episode
fields << 'parent']
show_page :field_list => { :fields => fields.join(',') }
So in DRYML:
<% fields = ['rock', 'kind']
fields << 'channel' if this.channel
fields << 'episode' if this.episode
fields << 'parent'] -%>
<show-page>
<field-list: fields="&fields.join(',')"/>
</show-page>
But, as suggested, this might be better as a helper.
I sometimes do this:
<show-page>
<field-list: fields="rock, kind#{', channel' if this.channel}#{',
episode' if this.episode}, parent"/>
</show-page>
But it's a bit hairy.
Another version is
<show-page>
<field-list: fields="&['rock', 'kind' ('channel' if this.channel),
('episode' if this.episode), 'parent'].compact"/>
</show-page>
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---