PHP Classes

File: examples.txt

Recommend this page to a friend!
  Classes of yaragn   Logic Template Engine   examples.txt   Download  
File: examples.txt
Role: ???
Content type: text/plain
Description: Examples Page
Class: Logic Template Engine
Process logic templates
Author: By
Last change:
Date: 23 years ago
Size: 2,834 bytes
 

Contents

Class file image Download
<? // users are recommended to get the latest source at www.servability.com/products/free/logictemplate/ /* +------------------------------------------------------------------------+ | Logic Template Engine (V2.01) - Examples | +------------------------------------------------------------------------+ | Copyright ©2000-2001 Servability Ltd. | +--------------------------------+---------------------------------------+ | Contributors: James Moore <jmoore@servability.com> | | James Kent <jkent@servability.com> | +------------------------------------------------------------------------+ Copyright (c) 2000-2001, Servability Ltd. http://www.servability.com/products/free/ info@servability.com. All rights reserved. License agreement contained in TemplateParser.class */ ?> // -- templates/test4.tpl -- [%IF TEST4_VAR1 == 1 %] TEST 4 HAS PASSED PART 1 [%IF TEST4_VAR2 == 1 %] TEST 4 HAS FAILED [%ELSEIF TEST4_VAR2 == 2 %] TEST 4 HAS PASSED PART 2 [%IF TEST4_VAR3 == 1 %] TEST 4 HAS FAILED [%ELSEIF TEST4_VAR3 == 2 %] TEST 4 HAS FAILED [%ELSE%] TEST 4 HAS PASSED PART 3 [%ENDIF%] [%ENDIF%] [%ELSE%] TEST 4 HAS FAILED [%ENDIF%] // -- test4.php -- <?php $test4 = new TemplateParser("./templates/"); // relative path $test4->addtemplate("template4","test4.tpl"); // add one or more templates (array) $test4->define("TEST4_VAR1","1"); // define variables $test4->define("TEST4_VAR2","2"); $test4->define("TEST4_VAR3","3"); $test4->define("TEST4_VAR4","4"); $test4->parse("test4out","template4"); // parse template4 into variable test4out echo $test4->output("test4out"); // output the result ?> // -- test5row.tpl -- [%TEST5_VAR1%]<br> // -- test5.tpl -- [%TEST5_ALLROWS%] // -- test5.php -- <?php // in this example a simple loop produces 10 instances of test5row.tpl, each parsed // appending into TEST5_ALLROWS. Then test5.tpl is parsed, replacing TEST5_ALLROWS // with the full set of rows. $test5 = new TemplateParser("./templates/"); $test5->addtemplate("template5","test5.tpl"); $test5->addtemplate("TEST5_ROW",strtolower("test5row.tpl")); // add row template FOR ($i=0; $i < 10; $i++) { // simple example loop $test5->define("TEST5_VAR1", $i); // simple definition making use of loop $test5->parse("TEST5_ALLROWS","TEST5_ROW",1); // additional parameter 1 for recursion } $test5->parse("test5out","template5"); $output = $test5->output("test5out"); // example, make Engine output to PHP variable echo $output; // output it echo "<!-- " . strlen($output) . " chars -->"; // output it's length as an html comment ?>