Show
Ignore:
Timestamp:
04/06/04 21:21:32 (5 years ago)
Author:
schst
Message:

updated docs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docs/extending-pattemplate.txt

    r85 r97  
    66--------------------- 
    77Variable modifiers will be applied to the value of a variable when 
    8 parsing the template. Currently you may pass any callable value 
    9 (function, object method or static method) as a variable modifier. 
     8parsing the template. There two types of modfifiers: 
     9 
     101.a) You may use any PHP function as a variable modifier. 
    1011The modifier must accept only a string as a parameter and also return 
    1112a string. Perfect examples for variable modifiers are nl2br() or 
    1213htmlentities(). 
    13 Complex variable modifiers (objects) will be described soon. 
     14 
     152.b) You may create custom modifiers. To do this, create a new file in 
     16 
     17  PATTEMPLATE_ROOT/patTemplate/Modifier 
     18   
     19or any of its sub-folders. In this file, you have to create a new class 
     20that's called 
     21 
     22  patTemplate_Modifier_FILENAME 
     23   
     24where FILENAME is the name of your file (and thus also of your modifier). 
     25If your modifier is located in a subfolder, you have to include the folder 
     26name in the class name, e.g. patTemplate_Modifier_Html_Image. 
     27 
     28Your class should inherit from patTemplate_Modifier and provide the following 
     29method: 
     30 
     31  string modify( string value, array params ) 
     32   
     33In the method you may modify the value and return it to the templating enginge. 
    1434 
    15352. Template Readers 
     
    73933. Custom Template Tags (functions) 
    7494----------------------------------- 
    75 Custom template tags are not supported, yet. 
     95Custom Tags allow you to extend patTemplate. You may define classes that 
     96are instantiated and evaluated,, when patTemplate finds a tag that is not 
     97supported by the engine. Custom functions are evaluated by the template reader. 
     98To create your own template function, create a new class that inherits from 
     99patTemplate_Function and place it into 
     100 
     101  PATTEMPLATE_ROOT/patTemplate/Function 
     102   
     103In this class you have to implement on function: 
     104 
     105  string call( array params, string content ) 
     106   
     107This method will be called on the closing tag with the same name as 
     108your file (and class). patTemplate_Reader will pass the attributes 
     109and the content of the tag to your method. You will then have to 
     110compute the data you want to insert to the template and return the 
     111string. This will be inserted instead of your custom tag. 
     112 
     113Custom Template Functions allow to do things like: 
     114 - Modify parts of the template while reading it 
     115 - Insert the current date/time 
     116 - Get request variables and insert them into the template 
     117 - ... 
     118 
     119Custom template functions (or tags) can also be called Horst. If you want to 
     120know, why they are called Horst, you could contact gERD or Argh. 
    76121 
    771224. Output Filters 
     
    176221---------------- 
    177222Output caches are not implemented, yet. 
     223They will be part of patTemplate 3.1.0