Horde_Template::parse PHP Method

parse() public method

Parses all variables/tags in the template.
public parse ( string $contents = null ) : string
$contents string The unparsed template.
return string The parsed template.
    public function parse($contents = null)
    {
        if (!is_null($contents)) {
            $this->setTemplate(str_replace("\n", " \n", $contents));
        }
        /* Evaluate the compiled template and return the output. */
        ob_start();
        eval('?>' . $this->_template);
        return is_null($contents) ? ob_get_clean() : str_replace(" \n", "\n", ob_get_clean());
    }

Usage Example

Example #1
0
 public function testScalar()
 {
     $template = new Horde_Template();
     $template->set('one', 'one');
     $template->set('two', 2);
     $this->assertEquals("one\n2", $template->parse("<tag:one />\n<tag:two />"));
 }
All Usage Examples Of Horde_Template::parse