Smarty Templates

Recently, I have been learning about, and working with smarty templates. These are effectively a php based templating system similar to xtemplates accept that they can have logic blocks in them. An example of the call in your index.html file would be as follows:

<?php
    $stuff=array();
    $smarty=new smarty;
    $smarty->assign('array', $stuff)
?>

Then in our index.tpl document using smarty, we could make a call as follows:

<body>
    {foreach from=$array item=option}
        {if $option.stuff=1}
            <p>Woo</p>
        {else}
            <p>not</p>
        {/if}
    {/foreach}
</body>

For more information about the specifics, and some good examples of smarty in action, go here.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: