Back to Zen homepage
There are three phases of transpilling the template code into HTML code:
Feel free to add your own extension int one of these two arrays, like the dummy one below. This function needs to be defined and added before the zen function is called, not in the template itself when the preprocessing already started. So the php function below was not defined here (only displayed), but in the test.php script that loads the zen and processes this file.
- Preprocessing where $zen_pre global array of preprocessors takes the code as their argument and returns the transpilled code. The output is PHP, so all curly bracket replacement for angle brackets with question marks happens here (Zen -> PHP).
- PHP phase where PHP executes the preprocessed code (PHP -> HTML).
- PostProcessing where $zen_post global array some afterworks can be done (HTML -> HTML).
Zen defines following functions that can be redefined:
These functions gets a single argument describing the error. The default behavior is
- $zen_errext is called when some Zen extension fails during its processing (in phase 1 or 3)
- $zen_errparse is called when the PHP evaluation of the generated code fails (in phase 2)keep silent, but can be redefined before the zen script executes. They are not perfect yet and require further improvement in various error scenarios.