Parse template to variable

Help
Hmm
2005-07-07
2013-04-09
  • Hmm
    Hmm
    2005-07-07

    I need to open a templatefile, and save the parsed results in a variable.

    Can anybody help me with an example?

     
    • Sven Eichler
      Sven Eichler
      2005-07-07

      http://www.sanisoft.com/phplib/manual/TemplateExamples.php
      http://www.phpbuilder.com/columns/david20000512.php3?page=2

      example is based of the article from phpbuilder.com:

      $my_color = "blue"; // we'll use this later

      $t = new Template("/home/mydir/mytemplates/");
          // create a template object named $t
      $t->set_file("MyFileHandle","MyTemplate.ihtml");
          // set MyFileHandle = our template file
      $t->set_var("some_color",$my_color);
          // set template variable some_color = $my_color value

      // save the parsed output in the variable $myvar
      $myvar = $t->parse("MyOutput","MyFileHandle");
          // set template variable MyOutput = parsed file