From d0b7317e10254490acbe748d1d8c1e04aaf8be6b Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 27 Jun 2012 21:09:07 +0200 Subject: Added new Tags to the standard library. * ste:in_array checks, if a value is in an array * ste:join joins an array with a glue string * ste:split splits a string with a delimiter to an array * ste:array_add adds an element to an array. --- docu/language_definition.html | 19 +++++++++++++++++++ docu/nd/files/stupid_template_engine-php.html | 12 ++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'docu') diff --git a/docu/language_definition.html b/docu/language_definition.html index c4dd98b..4cf4aaf 100644 --- a/docu/language_definition.html +++ b/docu/language_definition.html @@ -77,6 +77,10 @@
  • ste:inc
  • ste:dec
  • ste:date
  • +
  • ste:in_array
  • +
  • ste:join
  • +
  • ste:split
  • +
  • ste:array_add
  • @@ -498,5 +502,20 @@ Result:
    18. Sep. 2011, 16:49:20

    + +

    ste:in_array

    +

    Check, if a value is in an array. The tag takes the variable name of the array by parameter array.The value to test with will be taken from the tags content.

    +

    Returns empty text, if the value is not in the array, otherwise a non-empty text.

    + +

    ste:join

    +

    Join parts of an array together. The array's variable name goes to the array parameter. The tag's content will be used as the glue, i.e. this will be between two elements.

    +

    Returns the joined array

    + +

    ste:split

    +

    Split a text and write the parts to an array. The array parameter takes the variable name of the resulting array, the delim parameter the text to split by. The tag's content will be the text to split.

    + +

    ste:array_add

    +

    Adding an element to an array. The array parameter takes the variable name of the array. The key parameter takes the array key to map the value to, if omitted, the value will be appended to the end of the array. The value is the tag's content.

    + diff --git a/docu/nd/files/stupid_template_engine-php.html b/docu/nd/files/stupid_template_engine-php.html index 2d68e6b..1567591 100644 --- a/docu/nd/files/stupid_template_engine-php.html +++ b/docu/nd/files/stupid_template_engine-php.html @@ -63,17 +63,17 @@ if (browserType) {document.write("
    ");if (browserV

    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.

    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.

    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.

    -- cgit v1.2.3-70-g09d2