tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Tangra_Simple_Tple

Source Location: /core/tangra_simple_tple.class.php

Class Tangra_Simple_Tple

Class Overview

Implements interfaces:

Very basic template engine.

Used by installers of site templates (we don't want to configure "mastodont" template engine every time when we do installaton, do we?)

Located in /core/tangra_simple_tple.class.php [line 53]

Tangra_Class
   |
   --Tangra_Simple_Tple

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Property Summary
string   $left_delimiter   Left delimiter for tags. Default is {@
string   $right_delimiter   Right delimiter for tags. Default is @}
string   $tpl_path   Path to templates directory.
array   $vars   Contains assigned by Tangra_Simple_Tple::assign() values. This values will be used to replace all tags in the template.

[ Top ]
Method Summary
Tangra_Simple_Tple   __construct()   Sets template paths and throws exception if the path is not existing.
void   assign()   Assignes value to a key/tag.
void   assign_set_array()   Sets entire assigment array at once. Useful when array is loaded from file. Normally is not used by the users.
void   assign_strict()   Assignes value to a key/tag. Similar to Tangra_Simple_Tple::assign() but will throw exception if there is already added value with the same key.
boolean   check_tpl_var_name()   Checks if $tpl_var is "valid" key identifier
void   clear_all_assigns()   Clears all asigments.
void   display()   Parses and displays template file.
string   fetch()   Loads file specified by $tpl, parses it and returns it with all tags replaced with assigned values.
void   get_left_delimiter()   Gets left delimiter for the tags in the template
unknown   get_right_delimiter()   Gets right delimiter for the tags in the template
string   get_tpl_path()   Gets template path
void   set_left_delimiter()   Sets left delimiter for the tags in the template
unknown   set_right_delimiter()   Sets right delimiter for the tags in the template
void   set_tpl_path()   Sets template dir that will be used to compose the full path for the template file
string   _fetch()   Parses $content and returns it with all tags replaced with assigned values.

[ Top ]
Properties
string   $left_delimiter [line 77]

Left delimiter for tags. Default is {@

API Tags:
Access:  private


[ Top ]
string   $right_delimiter [line 84]

Right delimiter for tags. Default is @}

API Tags:
Access:  private


[ Top ]
string   $tpl_path [line 60]

Path to templates directory.

API Tags:
Access:  private


[ Top ]
array   $vars = array() [line 69]

Contains assigned by Tangra_Simple_Tple::assign() values. This values will be used to replace all tags in the template.

It is simple associative array $key => $value

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 94]

  Tangra_Simple_Tple __construct( [string $tpl_path = NULL], [string $ld = '{@'], [string $rd = '@}']  )

Sets template paths and throws exception if the path is not existing.

Parameters:
string   $tpl_path:  path to template directory
string   $ld:  left delimiter for tags. Default is {@
string   $rd:  right delimiter for tags. Default is @}

Information Tags:
Throws:  Tangra_Exception

[ Top ]
assign  [line 166]

  void assign( string $tpl_var, [string $value = null]  )

Assignes value to a key/tag.

Will throw exception if $tpl_var does not conform ereg("[a-zA-Z0-9_]+"), i.e. is not alphanumeric (with optional underscore)

Parameters:
string   $tpl_var: 
string   $value: 

API Tags:
Access:  public

Information Tags:
Throws:  Tangra_Exception

Implementation of:
I_Tple::assign()
Assignes value to variable in tple dataspace

[ Top ]
assign_set_array  [line 209]

  void assign_set_array( unknown_type $vars_array  )

Sets entire assigment array at once. Useful when array is loaded from file. Normally is not used by the users.

Throws exception if parameter is not an array.

Parameters:
unknown_type   $vars_array: 

API Tags:
Access:  public

Information Tags:
Throws:  Tangra_Exception

[ Top ]
assign_strict  [line 182]

  void assign_strict( string $tpl_var, any $value  )

Assignes value to a key/tag. Similar to Tangra_Simple_Tple::assign() but will throw exception if there is already added value with the same key.

Will throw exception if $tpl_var does not conform ereg("[a-zA-Z0-9_]+"), i.e. is not alphanumeric (with optional underscore)

Parameters:
string   $tpl_var:  key/tag name
any   $value: 

API Tags:
Access:  public

Information Tags:
Throws:  TE_Var_Already_Exists

[ Top ]
check_tpl_var_name  [line 291]

  boolean check_tpl_var_name( string $tpl_var  )

Checks if $tpl_var is "valid" key identifier

Parameters:
string   $tpl_var: 

API Tags:
Access:  private


[ Top ]
clear_all_assigns  [line 198]

  void clear_all_assigns( )

Clears all asigments.


API Tags:
Access:  public


[ Top ]
display  [line 109]

  void display( string $tpl  )

Parses and displays template file.

Parameters:
string   $tpl:  file to be showed

API Tags:
Access:  public


Implementation of:
I_Tple::display()
Displays the template

[ Top ]
fetch  [line 143]

  string fetch( string $tpl  )

Loads file specified by $tpl, parses it and returns it with all tags replaced with assigned values.

Parameters:
string   $tpl: 

API Tags:
Access:  public


Implementation of:
I_Tple::fetch()
Fetches and returns the template

[ Top ]
get_left_delimiter  [line 260]

  void get_left_delimiter( string $left_delimiter  )

Gets left delimiter for the tags in the template

Parameters:
string   $left_delimiter: 

API Tags:
Access:  public


[ Top ]
get_right_delimiter  [line 279]

  unknown get_right_delimiter( )

Gets right delimiter for the tags in the template


API Tags:
Access:  public


[ Top ]
get_tpl_path  [line 240]

  string get_tpl_path( )

Gets template path


API Tags:
Access:  public


[ Top ]
set_left_delimiter  [line 250]

  void set_left_delimiter( [string $left_delimiter = '{@$']  )

Sets left delimiter for the tags in the template

Parameters:
string   $left_delimiter: 

API Tags:
Access:  public


[ Top ]
set_right_delimiter  [line 270]

  unknown set_right_delimiter( [ $right_delimiter = '@}']  )

Sets right delimiter for the tags in the template

Parameters:
   $right_delimiter: 

API Tags:
Access:  public


[ Top ]
set_tpl_path  [line 222]

  void set_tpl_path( string $tpl_path  )

Sets template dir that will be used to compose the full path for the template file

Parameters:
string   $tpl_path: 

API Tags:
Access:  public


[ Top ]
_fetch  [line 120]

  string _fetch( string $content, [boolean $strip_unused_tags = true]  )

Parses $content and returns it with all tags replaced with assigned values.

Parameters:
string   $content:  content to be parsed
boolean   $strip_unused_tags:  if true will strip tags that are not replaced (this happens when there are tags in the $content but no values are provided for them with assign())

API Tags:
Return:  parsed content
Access:  public


[ Top ]