<!-- DEFINE $VAR = 'value' -->
that works great for setting simple variables.Problem is, it doesn't work for complex variables. It is not possible to join several string or use another template variable as value. I suggest to extend DEFINE syntax a bit to make it more powerful:
Code: Select all
<!-- DEFINE $VAR -->
value
<!-- ENDDEFINE -->
Use variables as value:
<!-- DEFINE $POST_AUTHOR -->{postrow.POST_AUTHOR}<-- ENDDEFINE -->
Use shorter conditional statements: The following code
Code: Select all
<!-- IF whatever --><!-- DEFINE $VAR = '1' --><!-- ELSE --><!-- DEFINE $VAR = '2' --><!-- ENDIF -->
Code: Select all
<!-- DEFINE $VAR --><!-- IF whatever -->1<!-- ELSE -->2<!-- ENDIF --><!-- ENDDEFINE -->
But the biggest advantage is it allows inserting content in other templates, similar to TWIG's blocks. For example, if in overall_header.html you have this code:
Code: Select all
<html>
<head>
header stuff here
{$HEADER_META}
</head>
<body>
stuff here
menu start
menu end
{$MENU_AFTER}
Code: Select all
<!-- DEFINE $HEADER_META -->{$HEADER_META}
<link rel="whatever" href="whatever" />
<!-- ENDDEFINE -->
<!-- INCLUDE overall_header.html -->
the rest of template
Code: Select all
<!-- BEGIN postrow -->
post stuff
<!-- IF postrow.SOMETHING -->
<!-- DEFINE $IMPORTANT_DATA -->
some important information inside current post that you want to display after all posts, using {postrow.WHATEVER} variables available only in this loop!
<!-- ENDDEFINE -->
<!-- ENDIF -->
more post stuff
<!-- END postrow -->
{$IMPORTANT_DATA}
Code: Select all
<!-- BEGIN postrow -->
<!-- DEFINE $POST_AUTHOR_LINK --><!-- IF postrow.U_POST_AUTHOR --><a href="{U_POST_AUTHOR}"<!-- ELSE --><span<!-- ENDIF --><!-- IF postrow.POSTER_COLOR --> style="color: {postrow.POSTER_COLOR}"<!-- ENDIF -->>{postrow.POSTER_NAME}<!-- IF postrow.U_POST_AUTHOR --></a><!-- ELSE --></span><!-- ENDIF --><!-- ENDDEFINE -->
<div class="postprofile">
<p class="post-author">{$POST_AUTHOR_LINK}</p>
</div>
<div class="post">
<p class="post-time">Posted by {$POST_AUTHOR_LINK} at {postrow.TIME}</p>
</div>
<!-- END postrow -->