-1

There are so many template engines out there. However, I am looking for something simple, fast and easy like the the phpBB3.0 Template System. Something simple like

$template->set_filenames(array(
'body' => 'your_template_file.html'

));

With similar templates using {L_SOME_VARIABLE} like output. I do not want to install phpbb because of the overhead. I need it to be simple but smart enough to where if I want to output json it will recognize when the last attribute is done not to output the leading ';'

I will be using it to output data in json, xml, txt, AOML and others pointing to its respective template, depending on the choice the user makes for desired data input.

I have looked at things like Smarty, but it seems a little much for me and there doesn't seem to be any easy json solutions.

If anyone has any simple solutions please let me know. I am unable to find this exact question on here.

gnat
  • 6,213
  • 108
  • 53
  • 73
Michael Hartmann
  • 574
  • 7
  • 24

1 Answers1

1

PHP itself is a template engine (currently you can do much much more using it, but basically it is template engine) - IMHO creating and using template engines inside template engine is a little bit silly ;)

What I would suggest is just something like this:

function renderTemplate($_file_, $_args_ = null, $_return_ = false) {
    if (is_array($_args_)) {
        extract($_args_, EXTR_SKIP);
    }
    if ($_return_) {
        ob_start();
        ob_implicit_flush(false);
        require('/mypath/to/templates/'.$_file_.'.php');
        return ob_get_clean();
    } else {
        require('/mypath/to/templates/'.$_file_.'.php');
    }
}
lupatus
  • 4,208
  • 17
  • 19