Dashboard > RIFE > ... > Templates > Alternative tag syntax
RIFE Log In | Sign Up   View a printable version of the current page.
Alternative tag syntax


Added by Geert Bevin, last edited by Steven Grimm on Jun 16, 2006  (view change) show comment
Labels: 
(None)

RIFE's regular template tag format, which masks the template engine tags as comments of the native data format, is handy in many cases. However, sometimes it's cumbersome to use and it's also not appropriate as content of XML or (X)HTML tag attributes. The latter actually even creates problems when used with XSLT. Additionally, people have different preferences regarding tag syntaxes. All this made use create a collection of alternative tag syntaxes so that everybody is able to at least find one he feels comfortable with.

invisible:

This is the regular tag format. Tags are specially marked XML or (X)HTML comments.

<!--I 'common.blueprint'/--> 
<!--V 'content'/--> 
<!--BV 'content'--> 
    <form action="<!--V 'SUBMISSION:FORM:myData'/-->" method="post"> 
        <!--V 'SUBMISSION:PARAMS:myData'/--> 
        <input name="name" value="<!--V 'PARAM:name'--><!--/V-->" /> 
        <input type="submit" value="That's who I am!" /> 
    </form> 
<!--/BV--> 
<!--B 'welcome'--> 
    <div>Hi <!--V 'PARAM:name'/-->, it's <!--V 'day'/-->!</div>
<!--/B-->

Notice that in this case we have "<!--" inside our HTML tag attributes. As noted above, this can cause problems. Read on for the solution.

compact:

This format is less verbose than the invisible format. These tags will show up as visible text if you're editing your template in an HTML editor; whether that's a plus or a minus is a matter of taste.

[!I 'common.blueprint'/] 
[!V 'content'/] 
[!BV 'content'] 
    <form action="[!V 'SUBMISSION:FORM:myData'/]" method="post"> 
        [!V 'SUBMISSION:PARAMS:myData'/] 
        <input name="name" value="[!V 'PARAM:name'][!/V]" /> 
        <input type="submit" value="That's who I am!" /> 
    </form> 
[!/BV] 
[!B 'welcome'] 
    <div>Hi [!V 'PARAM:name'/], it's [!V 'day'/]!</div>
[!/B]

Mixed invisible and compact

This is the most commonly used syntax, and demonstrates the way RIFE supports mixing tag formats as you see fit. The "invisible" format is used everywhere except in the attributes of HTML tags, where the nested "<" could confuse parsers.

<!--I 'common.blueprint'/--> 
<!--V 'content'/--> 
<!--BV 'content'--> 
    <form action="[!V 'SUBMISSION:FORM:myData'/]" method="post"> 
        <!--V 'SUBMISSION:PARAMS:myData'/--> 
        <input name="name" value="[!V 'PARAM:name'][!/V]" /> 
        <input type="submit" value="That's who I am!" /> 
    </form> 
<!--/BV--> 
<!--B 'welcome'--> 
    <div>Hi <!--V 'PARAM:name'/-->, it's <!--V 'day'/-->!</div>
<!--/B-->

Velocity inspired

These tags should look somewhat familiar to people that are used to Velocity. They will not become invisible if the template is viewed in a browser. These tags are safe to use both inside and outside of HTML tag attributes.

${i common.blueprint/}
${v content/}
${bv content}
    <form action="${v SUBMISSION:FORM:myData:/}" method="post">
        ${v SUBMISSION:PARAMS:myData/}
        <input name="name" value="${v PARAM:name}${/v}" />
        <input type="submit" value="That's who I am!" />
    </form>
${/bv}
${b welcome}
    <div>Hi ${v PARAM:name/}, ${v day/}!</div>
${/b}

Regular tags inspired

This version uses custom XHTML tags that look exactly the same as the rest of the layout code and that can easily get validation and auto-completion support in IDEs. In this example, we mix the regular tags inspired format with the compact format.

<r:i name="common.blueprint"/>
<r:v name="content"/>
<r:bv name="content">
    <form action="[!V 'SUBMISSION:FORM:myData'/]" method="post"> 
        <r:v name="SUBMISSION:PARAMS:myData"/>
        <input name="name" value="[!V 'PARAM:name'][!/V]" /> 
        <input type="submit" value="That's who I am!" />
    </form>
</r:bv>
<r:b name="welcome">
    <div>Hi <r:v name="PARAM:name"/>, it's <r:v name="day"/>!</div>
</r:b>

To make it convenient to use the regular tag variant, you can download the following support files:

DTD file: http://rifers.org/dtd/template_1_0.dtd
tag library descriptor: http://rifers.org/dtd/rife-template.tld



Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.1a Build:#515 May 19, 2006) - Bug/feature request - Contact Administrators