PHP CLASS:Spectre Template Engine 3.0.3

Discussion in 'PHP' started by astkboy2008, Dec 21, 2009.

?

did you love Spectre Template Engine

  1. yea,sure

    0 vote(s)
    0.0%
  2. i think its differ

    0 vote(s)
    0.0%
  1. #1
    Version 3 of the Template Engine is a complete rewrite of the template engine. This version increases performance as well as implements features that the previous versions did not include.

    Block support is now included as standard functionality for switching between sections of the page.

    Repeating Rows is now included as standard functionality to give the ability to repeat a specific block of code over and over again by sending an array of values to replace it with.
    Examples of usage
    HTML:
    
    <html>
    <body>
    <h1>{ tag1 }</h1>
    { tag2 }
    {block.start( BLOCK1 )}
      <div class="message">This is just a message that will only appear when this block is turned on.</div>
    {block.end( BLOCK1 )}
    
    <table>
    {row.start( row1 )}
      <tr>
        {row.start( row2 )}
         <td>{ field_name }</td>
         <td>{ tag3 }</td>
        {row.end( row2 )}
      </tr>
    {row.end( row1 )}
    </table>
    
    </body>
    </html>
    
    PHP:
    PHP:
    
    $oSpectre = new Spectre();
    
    $aTags = array(
      'tag1' => 'This is the Title',
      'tag2' => 'This is the content',
      'tag3' => 'random data',
    );
    
    // Simple Single Level rowset
    $aRows['ident'][]['tags'] = array(
      'tag' => value,
    );
    
    // Advanced nested rowset
    // as you can see below you can loop through and create them 
    // without a problem within a foreach lop
    $aRows['ident'][0]['rowset']['ident2'][]['tags'] = array('tag' => value);
    $aRows['ident'][0]['tags'] = array('tag' => value);
    $aRows['ident'][1]['rowset']['ident2'][]['tags'] = array('tag' => value);
    $aRows['ident'][1]['tags'] = array('tag' => value);
    
    // Set the initial template
    $oSpectre->setTemplate( 'path/to/template/file.ext' , 'template_ident' );
    $oSpectre->setTags( $aTags , 'template_ident' );
    $oSpectre->setBlock( 'BLOCK1' , 'show' , 'template_ident' );
    $oSpectre->setRows( $aRows , 'template_ident' );
    echo $oSpectre->parseTemplate( 'template_ident' );
    
    PHP:

    Download the class files from Jooria Refresh Your Website
    class.Spectre3.0.3.zip [5.63 KB]
    or view the class content
    class.Spectre.php [29.7 KB]
     
    astkboy2008, Dec 21, 2009 IP