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>
      <h2 class="menu-heading">
          <r:link>
              <r:title />
          </r:link>
      </h2>
      <r:if_url matches="/news/">
          <r:children:each limit="3" order="desc" by="published_at">
              <h3 class="menu-subheading">
                  <r:link>
                      <r:title />
                  </r:link>
              </h3>
          </r:children:each>
          <h3 class="menu-subheading">
              <r:link> More news... </r:link>
          </h3>
      </r:if_url>
      <r:unless_url matches="/news/">
          <r:children:each order="desc" by="published_at">
              <h3 class="menu-subheading">
                  <r:link>
                      <r:title />
                  </r:link>
              </h3>
          </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>
      <h2 class="menu-heading">
          <r:link>
              <r:title />
          </r:link>
      </h2>
      <r:ruby> @news = tag.locals.page.url =~ /news/; "" </r:ruby>
      <r:children:each limit="[EMAIL PROTECTED] ? '3':'1000'" order="desc"
by="published_at">
          <h3 class="menu-subheading">
              <r:link>
                  <r:title />
              </r:link>
          </h3>
      </r:children:each>
      <r:if cond="@news">
          <h3 class="menu-subheading">
              <r:link> More news... </r:link>
          </h3>
      </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
_______________________________________________
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to