From e78747b85b8a5cb55d31691b980824993286b188 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 4 Oct 2012 16:19:29 +0200 Subject: New docu and fixed mkdocu.sh mkdocu.sh will now test, if the executable is named "naturaldocs" or "NaturalDocs". --- docu/nd/files/stupid_template_engine-php.html | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'docu/nd/files/stupid_template_engine-php.html') diff --git a/docu/nd/files/stupid_template_engine-php.html b/docu/nd/files/stupid_template_engine-php.html index 1567591..91d6080 100644 --- a/docu/nd/files/stupid_template_engine-php.html +++ b/docu/nd/files/stupid_template_engine-php.html @@ -1,9 +1,9 @@ -stupid_template_engine.php - + @@ -23,15 +23,15 @@ if (browserType) {document.write("
");if (browserV

Functions

-

precompile

function precompile($code)

Precompiling STE T/PL templates.  You only need this function, if you want to manually transcompile a template.

Parameters

$codeThe input code

Returns

The precompiled code.

+

precompile

function precompile($code)

Precompiling STE T/PL templates.  You only need this function, if you want to manually transcompile a template.

Parameters

$codeThe input code

Returns

The precompiled code.

-

parse

function parse($code,
$tpl)

Parsing a STE T/PL template.  You only need this function, if you want to manually transcompile a template.

Parameters

$codeThe STE T/PL code.
$tplThe name of the template.

Returns

An abstract syntax tree, which can be used with transcompile.

+

parse

function parse($code,
$tpl)

Parsing a STE T/PL template.  You only need this function, if you want to manually transcompile a template.

Parameters

$codeThe STE T/PL code.
$tplThe name of the template.

Returns

An abstract syntax tree, which can be used with transcompile.

-

transcompile

function transcompile($ast) /* Transcompile and add some boilerplate code. */

Transcompiles an abstract syntax tree to PHP.  You only need this function, if you want to manually transcompile a template.

Parameters

$astThe abstract syntax tree to transcompile.

Returns

PHP code.  The PHP code is an anonymous function expecting a STECore instance as its parameter and returns a string (everything that was not pached into a section).

+

transcompile

function transcompile($ast) /* Transcompile and add some boilerplate code. */

Transcompiles an abstract syntax tree to PHP.  You only need this function, if you want to manually transcompile a template.

Parameters

$astThe abstract syntax tree to transcompile.

Returns

PHP code.  The PHP code is an anonymous function expecting a STECore instance as its parameter and returns a string (everything that was not pached into a section).

Constants

-

Template modes

MODE_SOURCEThe Templates source
MODE_TRANSCOMPILEDThe transcompiled template
+

Template modes

MODE_SOURCEThe Templates source
MODE_TRANSCOMPILEDThe transcompiled template

CantLoadTemplate

An exception that a StorageAccess implementation can throw, if it is unable to load a template.

@@ -41,41 +41,41 @@ if (browserType) {document.write("
");if (browserV

Functions

-

load

public function load($tpl,
&$mode)

Loading a template.

Parameters

$tplThe name of the template.
&$modeWhich mode is preferred?  One of the <Template modes>.  If <MODE_SOURCE>, the raw sourcecode is expected, if <MODE_TRANSCOMPILED> the transcompiled template as a callable function (expecting an STECore instance as first parameter) is expected.  If the transcompiled version is not available or older than the source, you can set this parameter to <MODE_SOURCE> and return the source.

Throws

A CantLoadTemplate exception if the template could not be loaded.

Returns

Either the sourcecode or a callable function (first, and only parameter: an STECore instance).

+

load

public function load($tpl,
&$mode)

Loading a template.

Parameters

$tplThe name of the template.
&$modeWhich mode is preferred?  One of the <Template modes>.  If <MODE_SOURCE>, the raw sourcecode is expected, if <MODE_TRANSCOMPILED> the transcompiled template as a callable function (expecting an STECore instance as first parameter) is expected.  If the transcompiled version is not available or older than the source, you can set this parameter to <MODE_SOURCE> and return the source.

Throws

A CantLoadTemplate exception if the template could not be loaded.

Returns

Either the sourcecode or a callable function (first, and only parameter: an STECore instance).

-

save

public function save($tpl,
$data,
$mode)

Saves a template.

Throws

A CantSaveTemplate exception if the template could not be saved.

Parameters

$tpl -The name of the template.  $data - The data to be saved.  $mode - A <Template mode> constant.

+

save

public function save($tpl,
$data,
$mode)

Saves a template.

Throws

A CantSaveTemplate exception if the template could not be saved.

Parameters

$tpl -The name of the template.  $data - The data to be saved.  $mode - A <Template mode> constant.

FilesystemStorageAccess

The default StorageAccess implementation for loading / saving templates into a directory structure.

Functions

-

__construct

public function __construct($src,
$transc)

Parameters

$srcThe directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
$transcThe directory with the transcompiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).
+

__construct

public function __construct($src,
$transc)

Parameters

$srcThe directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
$transcThe directory with the transcompiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).

STECore

The Core of STE

Summary
Variables
Public variables
Functions
__construct
register_tagRegister a custom tag.
call_tagCalling a custom tag (builtin ones can not be called)
exectemplateExecutes a template and returns the result.
get_var_referenceGet a reference to a template variable using a variable name.
set_var_by_nameSet a template variable by its name.
get_var_by_nameGet a template variable by its name.
loadLoad a template and return its result (blocks not included, use exectemplate for this).
evalboolTest, if a text represents false (an empty / only whitespace text) or true (everything else).

Variables

-

Public variables

$blocksAssociative array of blocks (see the language definition).
$blockorderThe order of the blocks (an array)
$varsAssociative array of all template variables.  Use this to pass data to your templates.
$mute_runtime_errorsIf True (default) a RuntimeError exception will result in no output from the tag, if False a error message will be written to output.
$fatal_error_on_missing_tagIf True, STE will throw a FatalRuntimeError if a tag was called that was not registered, otherwise (default) a regular RuntimeError will be thrown and automatically handled by STE (see <$mute_runtime_errors>).
+

Public variables

$blocksAssociative array of blocks (see the language definition).
$blockorderThe order of the blocks (an array)
$varsAssociative array of all template variables.  Use this to pass data to your templates.
$mute_runtime_errorsIf True (default) a RuntimeError exception will result in no output from the tag, if False a error message will be written to output.
$fatal_error_on_missing_tagIf True, STE will throw a FatalRuntimeError if a tag was called that was not registered, otherwise (default) a regular RuntimeError will be thrown and automatically handled by STE (see $mute_runtime_errors).

Functions

-

__construct

public function __construct($storage_access)

Parameters

$storage_accessAn Instance of a StorageAccess implementation.
+

__construct

public function __construct($storage_access)

Parameters

$storage_accessAn Instance of a StorageAccess implementation.
-

register_tag

public function register_tag($name,
$callback)

Register a custom tag.

Parameters

$nameThe name of the tag.
$callbackA callable function (This must tage three parameters: The STECore instance, an associative array of parameters, and a function representing the tags content(This expects the STECore instance as its only parameter and returns its text result, i.e to get the text, you neeed to call this function with the STECore instance as a parameter)).

Throws

An Exception if the tag could not be registered (if $callback is not callable or if $name is empty)

+

register_tag

public function register_tag($name,
$callback)

Register a custom tag.

Parameters

$nameThe name of the tag.
$callbackA callable function (This must tage three parameters: The STECore instance, an associative array of parameters, and a function representing the tags content(This expects the STECore instance as its only parameter and returns its text result, i.e to get the text, you neeed to call this function with the STECore instance as a parameter)).

Throws

An Exception if the tag could not be registered (if $callback is not callable or if $name is empty)

-

call_tag

public function call_tag($name,
$params,
$sub)

Calling a custom tag (builtin ones can not be called)

Parameters

$nameThe Tag’s name
$paramsAssociative array of parameters
$subA callable function (expecting an STECore instance as it’s parameter) that represents the tag’s content.

Throws

Might throw a FatalRuntimeError (see $fatal_error_on_missing_tag.

Returns

The output of the tag or, if a RuntimeError was thrown, the appropiate result (see <$mute_runtime_errors>).

+

call_tag

public function call_tag($name,
$params,
$sub)

Calling a custom tag (builtin ones can not be called)

Parameters

$nameThe Tag’s name
$paramsAssociative array of parameters
$subA callable function (expecting an STECore instance as it’s parameter) that represents the tag’s content.

Throws

Might throw a FatalRuntimeError (see $fatal_error_on_missing_tag.

Returns

The output of the tag or, if a RuntimeError was thrown, the appropiate result (see $mute_runtime_errors).

-

exectemplate

public function exectemplate($tpl)

Executes a template and returns the result.  The huge difference to load is that this function will also output all blocks.

Parameters

$tplThe name of the template to execute.

Throws

Returns

The output of the template.

+

exectemplate

public function exectemplate($tpl)

Executes a template and returns the result.  The huge difference to load is that this function will also output all blocks.

Parameters

$tplThe name of the template to execute.

Throws

Returns

The output of the template.

-

get_var_reference

public function &get_var_reference($name,
$create_if_not_exist)

Get a reference to a template variable using a variable name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.
$create_if_not_existShould the variable be created, if it does not exist?  Otherwise NULL will be returned, if the variable does not exist.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

Returns

A Reference to the variable.

+

get_var_reference

public function &get_var_reference($name,
$create_if_not_exist)

Get a reference to a template variable using a variable name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.
$create_if_not_existShould the variable be created, if it does not exist?  Otherwise NULL will be returned, if the variable does not exist.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

Returns

A Reference to the variable.

-

set_var_by_name

public function set_var_by_name($name,
$val)

Set a template variable by its name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.
$valThe new value.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

+

set_var_by_name

public function set_var_by_name($name,
$val)

Set a template variable by its name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.
$valThe new value.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

-

get_var_by_name

public function get_var_by_name($name)

Get a template variable by its name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

Returns

The variables value.

+

get_var_by_name

public function get_var_by_name($name)

Get a template variable by its name.  This can be used,if your custom tag takes a variable name as a parameter.

Parameters

$nameThe variables name.

Throws

RuntimeError if the variable name can not be parsed (e.g. unbalanced brackets).

Returns

The variables value.

-

load

public function load($tpl,  
$quiet = False)

Load a template and return its result (blocks not included, use exectemplate for this).

Parameters

$tplThe name of the template to be loaded.
$quietIf true, do not output anything and do notmodify the blocks.  This can be useful to load custom tags that are programmed in STE T/PL.  Default: false.

Throws

Returns

The result of the template (if $quiet == false).

+

load

public function load($tpl,  
$quiet = False)

Load a template and return its result (blocks not included, use exectemplate for this).

Parameters

$tplThe name of the template to be loaded.
$quietIf true, do not output anything and do notmodify the blocks.  This can be useful to load custom tags that are programmed in STE T/PL.  Default: false.

Throws

Returns

The result of the template (if $quiet == false).

-

evalbool

public function evalbool($txt)

Test, if a text represents false (an empty / only whitespace text) or true (everything else).

Parameters

$txtThe text to test.

Returns

true/false.

+

evalbool

public function evalbool($txt)

Test, if a text represents false (an empty / only whitespace text) or true (everything else).

Parameters

$txtThe text to test.

Returns

true/false.

@@ -90,7 +90,7 @@ var searchPanel = new SearchPanel("searchPanel", "HTML", "../search"); -
function precompile($code)
Precompiling STE T/PL templates.
function parse($code,
$tpl)
Parsing a STE T/PL template.
function transcompile($ast) /* Transcompile and add some boilerplate code. */
Transcompiles an abstract syntax tree to PHP.
An interface.
public function load($tpl,
&$mode)
Loading a template.
public function save($tpl,
$data,
$mode)
Saves a template.
public function __construct($src,
$transc)
public function __construct($storage_access)
public function register_tag($name,
$callback)
Register a custom tag.
public function call_tag($name,
$params,
$sub)
Calling a custom tag (builtin ones can not be called)
public function exectemplate($tpl)
Executes a template and returns the result.
public function &get_var_reference($name,
$create_if_not_exist)
Get a reference to a template variable using a variable name.
public function set_var_by_name($name,
$val)
Set a template variable by its name.
public function get_var_by_name($name)
Get a template variable by its name.
public function load($tpl,  
$quiet = False)
Load a template and return its result (blocks not included, use exectemplate for this).
public function evalbool($txt)
Test, if a text represents false (an empty / only whitespace text) or true (everything else).
If True (default) a RuntimeError exception will result in no output from the tag, if False a error message will be written to output.
The Core of STE
An exception that a StorageAccess implementation can throw, if it is unable to load a template.
An exception that a StorageAccess implementation can throw, if it is unable to save a template.
An Exception that a tag can throw, if a non-fatal runtime error occurred.
An Exception a tag can throw, if a fatal (irreparable) runtime error occurred.
If True, STE will throw a FatalRuntimeError if a tag was called that was not registered, otherwise (default) a regular RuntimeError will be thrown and automatically handled by STE (see <$mute_runtime_errors>).
+
function precompile($code)
Precompiling STE T/PL templates.
function parse($code,
$tpl)
Parsing a STE T/PL template.
function transcompile($ast) /* Transcompile and add some boilerplate code. */
Transcompiles an abstract syntax tree to PHP.
An interface.
public function load($tpl,
&$mode)
Loading a template.
public function save($tpl,
$data,
$mode)
Saves a template.
public function __construct($src,
$transc)
public function __construct($storage_access)
public function register_tag($name,
$callback)
Register a custom tag.
public function call_tag($name,
$params,
$sub)
Calling a custom tag (builtin ones can not be called)
public function exectemplate($tpl)
Executes a template and returns the result.
public function &get_var_reference($name,
$create_if_not_exist)
Get a reference to a template variable using a variable name.
public function set_var_by_name($name,
$val)
Set a template variable by its name.
public function get_var_by_name($name)
Get a template variable by its name.
public function load($tpl,  
$quiet = False)
Load a template and return its result (blocks not included, use exectemplate for this).
public function evalbool($txt)
Test, if a text represents false (an empty / only whitespace text) or true (everything else).
If True (default) a RuntimeError exception will result in no output from the tag, if False a error message will be written to output.
The Core of STE
An exception that a StorageAccess implementation can throw, if it is unable to load a template.
An exception that a StorageAccess implementation can throw, if it is unable to save a template.
An Exception that a tag can throw, if a non-fatal runtime error occurred.
An Exception a tag can throw, if a fatal (irreparable) runtime error occurred.
If True, STE will throw a FatalRuntimeError if a tag was called that was not registered, otherwise (default) a regular RuntimeError will be thrown and automatically handled by STE (see $mute_runtime_errors).
-- cgit v1.2.3-70-g09d2