Compdigitec Labs

« | Home | »

Simple Template Engine – your lightweight templating engine in PHP

By admin | February 2, 2009

The Simple Template Engine is a very lightweight template engine to use in PHP if your webhost does not allow you to run something like Smarty. It is simple, lightweight and fast.

To parse a file:

<?php

// include simple template engine
include("tpl.class.php");

$tpl = new template();

$tpl->assign(Array('content'=>"Hello World from Simple Template Engine!"));

// If you want to display it directly
$tpl->display('example.tpl');

// If you want to send it to another function/class for more processing
some_function($tpl->parse('example.tpl'));

?>

example.tpl is:

<html><head><title>{content}</title></head><body><h1>{content}</h1></body></html>

If you found this article useful or helpful, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: (X)HTML, PHP | 21 Comments »

21 Responses to “Simple Template Engine – your lightweight templating engine in PHP”

  1. andrew Says:
    March 4th, 2009 at 08:51

    Hi!
    Very nice template system 😉

    I wonder how can I use php code in the template file? Is it possible?

    Thanks

  2. admin Says:
    March 7th, 2009 at 05:38

    @andrew:

    Where you would use:

    You would use:

    (template code)
    Test is %number%

    (php code)
    assign(Array(‘number’=>strval($s)));
    $tpl->display(‘template.tpl’);

    ?>

  3. nova9 Says:
    February 10th, 2022 at 23:35

    … [Trackback]

    […] Find More Info here to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  4. บาคาร่า วอเลท Says:
    February 13th, 2022 at 07:06

    … [Trackback]

    […] There you will find 23191 additional Information to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  5. สล็อตแตกง่าย Says:
    February 14th, 2022 at 11:17

    … [Trackback]

    […] Find More here on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  6. 애니위크 Says:
    February 27th, 2022 at 07:46

    … [Trackback]

    […] Read More Information here on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  7. concur business solutions Says:
    April 14th, 2022 at 09:52

    … [Trackback]

    […] There you can find 43979 additional Info on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  8. devops consulting services Says:
    May 26th, 2022 at 14:32

    … [Trackback]

    […] Read More Info here to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  9. how do i get psilocybin​ Says:
    June 20th, 2022 at 06:05

    … [Trackback]

    […] Here you will find 71521 additional Info on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  10. สล็อตวอเลท ไม่มีขั้นต่ำ Says:
    July 12th, 2022 at 19:53

    … [Trackback]

    […] Find More Info here on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  11. Bassetti Bademantel bestellen Says:
    July 20th, 2022 at 08:38

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  12. psilocybin oakland where to buy​ Says:
    July 20th, 2022 at 19:39

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  13. tijeras de jardineria Says:
    September 8th, 2022 at 13:23

    … [Trackback]

    […] Find More on on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  14. cc fullz Says:
    September 26th, 2022 at 17:28

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  15. maxbet Says:
    December 4th, 2022 at 09:31

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  16. Bassetti günstig bestellen Says:
    December 18th, 2022 at 09:36

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  17. learn more Says:
    February 4th, 2023 at 01:04

    … [Trackback]

    […] Find More on on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  18. สินเชื่อโฉนดที่ดินเปล่า Says:
    February 7th, 2023 at 00:53

    … [Trackback]

    […] Read More Info here on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  19. top article Says:
    February 24th, 2023 at 09:45

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  20. Buy DMT vape Australia Says:
    March 9th, 2023 at 12:22

    … [Trackback]

    […] Here you will find 59728 more Info to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

  21. สล็อตเว็บตรง Says:
    March 13th, 2023 at 20:23

    … [Trackback]

    […] Find More Info here to that Topic: compdigitec.com/labs/2009/02/02/simple-template-engine-your-lightweight-templating-engine-in-php/ […]

Comments