Class **Phalcon\\Mvc\\View\\Engine\\Volt\\Compiler** ==================================================== *implements* :doc:`Phalcon\\Di\\InjectionAwareInterface ` .. role:: raw-html(raw) :format: html :raw-html:`Source on GitHub` This class reads and compiles Volt templates into PHP plain code .. code-block:: php compile('views/partials/header.volt'); require $compiler->getCompiledTemplatePath(); Methods ------- public **__construct** ([:doc:`Phalcon\\Mvc\\ViewBaseInterface ` $view]) public **setDI** (:doc:`Phalcon\\DiInterface ` $dependencyInjector) Sets the dependency injector public **getDI** () Returns the internal dependency injector public **setOptions** (*array* $options) Sets the compiler options public **setOption** (*string* $option, *mixed* $value) Sets a single compiler option public *string* **getOption** (*string* $option) Returns a compiler's option public **getOptions** () Returns the compiler options final public *mixed* **fireExtensionEvent** (*string* $name, [*array* $arguments]) Fires an event to registered extensions public **addExtension** (*unknown* $extension) Registers a Volt's extension public **getExtensions** () Returns the list of extensions registered in Volt public **addFunction** (*unknown* $name, *unknown* $definition) Register a new function in the compiler public **getFunctions** () Register the user registered functions public **addFilter** (*unknown* $name, *unknown* $definition) Register a new filter in the compiler public **getFilters** () Register the user registered filters public **setUniquePrefix** (*unknown* $prefix) Set a unique prefix to be used as prefix for compiled variables public **getUniquePrefix** () Return a unique prefix to be used as prefix for compiled variables and contexts public **attributeReader** (*array* $expr) Resolves attribute reading public **functionCall** (*array* $expr) Resolves function intermediate code into PHP function calls public **resolveTest** (*array* $test, *unknown* $left) Resolves filter intermediate code into a valid PHP expression final protected **resolveFilter** (*array* $filter, *unknown* $left) Resolves filter intermediate code into PHP function calls final public **expression** (*array* $expr) Resolves an expression node in an AST volt tree final protected *string|array* **_statementListOrExtends** (*array* $statements) Compiles a block of statements public **compileForeach** (*array* $statement, [*unknown* $extendsMode]) Compiles a "foreach" intermediate code representation into plain PHP code public **compileForElse** () Generates a 'forelse' PHP code public **compileIf** (*array* $statement, [*unknown* $extendsMode]) Compiles a 'if' statement returning PHP code public **compileElseIf** (*array* $statement) Compiles a "elseif" statement returning PHP code public **compileCache** (*array* $statement, [*unknown* $extendsMode]) Compiles a "cache" statement returning PHP code public **compileSet** (*array* $statement) Compiles a "set" statement returning PHP code public **compileDo** (*array* $statement) Compiles a "do" statement returning PHP code public **compileReturn** (*array* $statement) Compiles a "return" statement returning PHP code public **compileAutoEscape** (*array* $statement, *unknown* $extendsMode) Compiles a "autoescape" statement returning PHP code public *string* **compileEcho** (*array* $statement) Compiles a '{{' '}}' statement returning PHP code public **compileInclude** (*array* $statement) Compiles a 'include' statement returning PHP code public **compileMacro** (*array* $statement, *unknown* $extendsMode) Compiles macros public *string* **compileCall** (*array* $statement, *boolean* $extendsMode) Compiles calls to macros final protected **_statementList** (*array* $statements, [*unknown* $extendsMode]) Traverses a statement list compiling each of its nodes protected **_compileSource** (*unknown* $viewCode, [*unknown* $extendsMode]) Compiles a Volt source code returning a PHP plain version public **compileString** (*unknown* $viewCode, [*unknown* $extendsMode]) Compiles a template into a string .. code-block:: php compileString('{{ "hello world" }}'); public *string|array* **compileFile** (*string* $path, *string* $compiledPath, [*boolean* $extendsMode]) Compiles a template into a file forcing the destination path .. code-block:: php compile('views/layouts/main.volt', 'views/layouts/main.volt.php'); public **compile** (*unknown* $templatePath, [*unknown* $extendsMode]) Compiles a template into a file applying the compiler options This method does not return the compiled path if the template was not compiled .. code-block:: php compile('views/layouts/main.volt'); require $compiler->getCompiledTemplatePath(); public **getTemplatePath** () Returns the path that is currently being compiled public **getCompiledTemplatePath** () Returns the path to the last compiled template public *array* **parse** (*string* $viewCode) Parses a Volt template returning its intermediate representation .. code-block:: php parse('{{ 3 + 2 }}'));