Login   Register  
PHP Classes
elePHPant
Icontem

File: operators.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ilya  >  APEx - Template Abstraction Layer  >  operators.txt  >  Download  
File: operators.txt
Role: Documentation
Content type: text/plain
Description: Guide to write own operators
Class: APEx - Template Abstraction Layer
Flexible compiling template system
Author: By
Last change:
Date: 11 years ago
Size: 2,044 bytes
 

Contents

Class file image Download
Operators definition syntax.

Fields:
"type" operator type
 * "single" - <tag />
 * "double" - <tag> [<option>] </tag>
 * in project "multi" - <tag><subtag></subtag></tag>
"tag" tag name
"replace" tag replace. You can use following vars:
 * %varname% - subst value of the variable with "varname"
 * %number% - subst unnamed var with number "number" (vars count begin from 1)
 * %0% - subst varstring "as is", except substitution of the registered vars (see below)
 * %?digit% - subst script-allocated var. All vars with the same digit "digit" will have the same names.
 * %replace% - if used for "double" tags only. Subst all content stored within matched tags.
"vars" array of the vars handlers. If handler is defined then result of its work would be put to "replace".
   Possible fields:
 * varname - handler for the "varname" var.
 * 0 - handler for full string.
 * replace - handler for the %replace%
"register" array of vars to be put in Globals.
"help" short description.

Example:
             // type
$op = array ("type" => "single", 
             // name
             "tag" => "datasource", 
             // replace
             "replace" => '<?php $this->_assignData("%name%","%function%",%0%) ?>',
             // handlers
             "vars" => array (// 0 matches all var1= ... var999= variables
                              "0" => '$a = "";
                                      foreach ($var as $k=>$v) $a.=preg_match("/var(\d+)$/",$k,$m)?",".$v:"";
                                      return $a;',
                              "folder" => 'return ($var=="this")?getcwd():strtr($var,"\\\\","/");',
                              "name" => 'return trim($var,"@");',
                             ),
             // vars to be registered
             "register" => array ("name"),
             // description
             "help" => "syntax: <datasource name='varname' function='any_function' var1='value1' var999='value999' />. Evaluates the function with given variables",
            );