Hi there!,
New feature: Attribute expansion. From the README:
---- 8< ----
== Attribute expansion
Back Door allows evaluating tag’s attributes as Ruby code. If a tag’s
attribute starts with the “#” symbol, the rest of the attribute is
evaluated, and the attribute’s value is replaced with the evaluated
value.
This works for both standard Radiant (Radius) tags and Back Door’s own
tags.
As an example, consider a side-bar where we want to show first and
second
level pages. But for the “news” page, we want to limit the number of
children to 3 and add an extra link to see all news. Without Back Door
this
could be implemented as:
<r:children:each>
<r:link>
<r:title />
</r:link>
<r:if_url matches="/news/">
<r:children:each limit=“3” order=“desc” by=“published_at”>
<r:link>
<r:title />
</r:link>
</r:children:each>
<r:link> More news… </r:link>
</r:if_url>
<r:unless_url matches="/news/">
<r:children:each order=“desc” by=“published_at”>
<r:link>
<r:title />
</r:link>
</r:children:each>
</r:unless_url>
</r:children:each>
Clearly there is too much duplication. With Back Door this can be
rewritten
as:
<r:children:each>
<r:link>
<r:title />
</r:link>
<r:ruby> @news = tag.locals.page.url =~ /news/; “” </r:ruby>
<r:children:each limit="#@news ? ‘3’:‘1000’" order=“desc”
by=“published_at”>
<r:link>
<r:title />
</r:link>
</r:children:each>
<r:if cond="@news">
<r:link> More news… </r:link>
</r:if>
</r:children:each>
Note how the “limit” attribute of the <r:children:each> tag uses the “#”
symbol to make it dynamic.
---- 8< ----
/AITOR