You can control the output-style via the options
passed to the constructor.
Different output types are possible (Currently, XML ,HTML and XHTML)
The main entry point is the compile method
The generated PHTML/PXML should be evaluated, the best method
is a simple include of a generated file
Usage example:
use Tale\Jade\Compiler;
$compiler = new Compiler();
$phtml = $compiler->compile($jadeInput);
or
$phtml = $compiler->compileFile($jadeFilePath);
There are different approachs to handle the compiled PHTML.
The best and most explaining one is saving the PHTML to a file and
including it like this:
file_put_contents('rendered.phtml', $phtml);
Define some variables to pass to our template
$variables = [
'title' => 'My Page Title!',
'posts' => []
];
Make sure the variables are accessible by the included template
extract($variables);
Compiler needs an $__args variables to pass arguments on to mixins
$__args = $variables;
Include the rendered PHTML directly
include('rendered.phtml');
You may fetch the included content with ob_start() and ob_get_clean()
and pass it on to anything, e.g. a cache handler or return it as an
AJAX response.