$_options : array
The options-array for the renderer instance.
Allows easy rendering of Jade-files to markup.
The renderer provides utilities to quickly render jade files to HTML/XML-output or/and to files
use Tale\Jade\Renderer; $renderer = new Renderer(); echo $renderer->render('index'); //Where "index" is a "index.jade" jade source file
$_compiler : \Tale\Jade\Compiler
The compiler that is used in this renderer instance.
$_parser : \Tale\Jade\Parser
The parser that is used in this renderer instance.
$_lexer : \Tale\Jade\Lexer
The lexer that is used in this renderer instance.
$_adapter : \Tale\Jade\Renderer\AdapterBase
The adapter that actually renders the files in a dynamic manner.
__construct(array|null $options = null, \Tale\Jade\Compiler|null $compiler = null, \Tale\Jade\Parser|null $parser = null, \Tale\Jade\Lexer|null $lexer = null)
Creates a new Tale Jade Renderer instance to render Jade files.
Use the ->render() method on the resulting object to render your jade files
Possible options are:
adapter: The name of the adapter to use, either a short-name for an internal adapter or a class-name for a custom adapter adapterOptions: The option-array that gets passed to the adapter compiler: The compiler-options that get passed to the compiler parserOptions: The parser-options that get passed to the parser lexerOptions: The lexer options that get passed to the lexer
pretty: Compile with indentations and newlines (default: false) paths: The paths the compiler should search the jade files in
the options to pass to the renderer
the compiler to use inside the renderer
the parser to use inside the compiler
the lexer to use inside the parser
getCompiler() : \Tale\Jade\Compiler
Return the compiler instance used in this renderer instance.
getParser() : \Tale\Jade\Parser
Returns the parser instance used in this renderer instance.
getLexer() : \Tale\Jade\Lexer
Returns the lexer used in this renderer instance.
addFilter(string $name, callable $callback) : $this
Adds a new filter to the compiler.
The filter can be called inside jade via the :
The signature of the callback should be (Node $node, $indent, $newLine) where $node is the filter node that was encountered (including its children) and $indent and $newLine are indentation and the new line character as a string respecting the compiler's 'pretty' option
This is just a proxy for the Compiler's addFilter method
getAdapter() : \Tale\Jade\Renderer\AdapterBase
Returns the adapter that actually renders the files.
This is lazy, meaning that the adapter gets created and stored as soon as the method is called the first time. After that all calls will return the same adapter instance
compile(string $input, string|null $path = null) : mixed|string
Compiles a Jade-string to PHTML.
The result can then be evaluated, the best method is a simple PHP include
Use ->render() to get this done for you
Before evaluating you should set a $__args variable that will be passed through mixins. It like a global scope.
If you give it a path, the directory of that path will be used for relative includes.
the jade input string
the path for relative includes
A PHTML string containing HTML and PHP
compileFile(string $path) : mixed|string
Compiles a file to PHTML.
The given path will automatically passed as compile()'s $path argument
The path should always be relative to the paths-option paths
The path to the jade file
when the file wasnt found or the compilation, lexing or parsing failed
the compiled PHTML
render(string $file, array|null $args = null) : string
Renders a jade-file to a markup-string directly.
This is the essence of the Jade-renderer and is the shortest and easiest way to get Jade running in your project
Notice that if your file wasn't found, you need to pass relative paths.
The paths will be relative from the compiler:paths option or from get_include_path(), if no paths have been defined
the relative path to the file to render
an array of variables to pass to the Jade-file
The renderered markup