DRYML: How to not show tag parameters that are empty

1 view
Skip to first unread message

Steve DeBaun

unread,
Oct 17, 2008, 7:13:46 PM10/17/08
to Hobo Users
<def tag="block">
<div class='block' merge-attrs>
<h3 param="title"/>
<h4 param="subtitle"/>
<h5 param="sidenote"/>
<p param="content"/>
<p param="footer"/>
</div>
</def>

How do I make it so tags without parameters passed don't get shown?
E.g. if I don't put a <subtitle:> tag, it still makes an empty <h4>
element.

I saw in the generated code stuff that put "if" at the end of the
parameter, so I tried that... at which point it stopped showing the
parameter everywhere.

sd

Steve DeBaun

unread,
Oct 19, 2008, 2:54:19 PM10/19/08
to Hobo Users
Found the solution:

<h3 param="title" if="&all_parameters.title?"/>

It looked like if-content should work as shorthand for
if="&all_parameters.title?", but it didn't. I also expected
"&parameters.title?" to work, but it didn't.

sd

Tom Locke

unread,
Oct 20, 2008, 3:32:32 AM10/20/08
to hobo...@googlegroups.com
all_parameters[:title] will be slightly more efficient. Your version
will actually evaluate the parameter and discard the result.

Tom

Reply all
Reply to author
Forward
0 new messages