Function __global->compile_template

Definitions

sources/tempcode_compiler.php

  • Compile a template into a list of appendable outputs, for the closure-style Tempcode implementation.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$data string No No required parameter N/A N/A The template file contents
$template_name ID_TEXT No No required parameter N/A N/A The name of the template (blank: not from a file)
$theme ID_TEXT No No required parameter N/A N/A The name of the theme
$lang ID_TEXT No No required parameter N/A N/A The language it is for
$tolerate_errors boolean No No False N/A N/A Whether to tolerate errors
&$parameters ?array Yes No Null N/A N/A Parameters to hard-code in during compilation (null: no hard-coding)
&$parameters_used ?array Yes No Null N/A N/A Parameters used in final Tempcode will be written into here (null: don't)
$suffix ?string No No Null .tpl .js .xml .txt .css N/A File type suffix of template file (e.g. .tpl) (null: not from a file)
$directory ?string No No Null N/A N/A Subdirectory type to look in (null: not from a file)

Returns

  • A pair: array Compiled result structure, array preprocessable bits (special stuff needing attention that is referenced within the template)
  • Type: array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Compile a template into a list of appendable outputs, for the closure-style Tempcode implementation.
 *
 * @param  string $data The template file contents
 * @param  ID_TEXT $template_name The name of the template (blank: not from a file)
 * @param  ID_TEXT $theme The name of the theme
 * @param  ID_TEXT $lang The language it is for
 * @param  boolean $tolerate_errors Whether to tolerate errors
 * @param  ?array $parameters Parameters to hard-code in during compilation (null: no hard-coding)
 * @param  ?array $parameters_used Parameters used in final Tempcode will be written into here (null: don't)
 * @param  ?string $suffix File type suffix of template file (e.g. .tpl) (null: not from a file)
 * @set .tpl .js .xml .txt .css
 * @param  ?string $directory Subdirectory type to look in (null: not from a file)
 * @return array A pair: array Compiled result structure, array preprocessable bits (special stuff needing attention that is referenced within the template)
 */

function compile_template(string $data, string $template_name, string $theme, string $lang, bool $tolerate_errors = false, ?array &$parameters = null, ?array &$parameters_used = null, ?string $suffix = null, ?string $directory = null) : array