fxl_template
[ class tree: fxl_template ] [ index: fxl_template ] [ all elements ]

Class: fxl_template

Source Location: /fxl_template.inc.php

Class Overview


fxl_template


Author(s):

Version:

  • 2.1.1

Methods


Child classes:

fxl_memcached_template
FXL Template - Memcache Extension (alpha, 0.5)

Class Details

[line 77]
fxl_template

a very tiny but flexible library for template processing

Have a look into the examples directory for some useful examples incl. template files.

Goals of this library:

  • plain text/html templates without any control mechanisms like loops, php code or sql queries
  • easy to learn template markup (only 2 elements)
  • flexibility: you can more or less assign everything to everywhere
  • speed
  • easy handling: It's just this tiny file you have to include to use fxl template




Tags:

version:  2.1.1


[ Top ]


Class Methods


constructor __construct [line 108]

object fxl_template __construct( [string $content = false], [array $options = false])

fxl_template constructor

example:

  1.  $tpl new fxl_template('template.tpl');




Tags:

access:  public


Overridden in child classes as:

fxl_memcached_template::__construct()
Constructor

Parameters:

string   $content   file name
array   $options   not in use

[ Top ]

method assign [line 176]

void assign( string|array $var, [string|object $val = null])

new assignment

complete example:

  1.  $tpl new fxl_template('address_form.tpl');
  2.  $tpl_address $tpl->get_block('address');
  3.  $tpl_address->assign('name''Peter');
  4.  $tpl_address->assign(array('zip' => '10179''town' => 'Berlin'));
  5.  $tpl->assign('address'$tpl_address);
  6.  $tpl->display();

usage examples:

  1.  $tpl->assign(<string var><string val>);
  2.  $tpl->assign(<string var><object fxl_template>);
  3.  $tpl->assign(<string blockname><object fxl_template>);
  4.  $tpl->assign(<array [var=val,var=val]>);
  5.  $tpl->assign(<string blockname>)*
  6.  $tpl->assign(<string blockname>val);

* since version 2.1.1




Tags:

since:  1.0.0
access:  public


Parameters:

string|array   $var   string: name of the block / place holder OR array with key/value pairs
string|object    $val   string OR object (another FXL Template object)

[ Top ]

method assign_block [line 202]

void assign_block( string $blockname)

assigns a whole block in place

  1.  $tpl->assign_block('blockname');
  2.  
  3.  same as:
  4.  $tpl_block $tpl->get_block('blockname');
  5.  $tpl->assign('blockname'$tpl_block);
  6.  
  7.  same as:
  8.  $tpl->assign('blockname');




Tags:

access:  public


Parameters:

string   $blockname   block name

[ Top ]

method block_exists [line 233]

bool block_exists( string $blockname)

checks a block exists or not



Tags:

since:  2.0.0
access:  public


Parameters:

string   $blockname   block name

[ Top ]

method clear [line 257]

void clear( )

refresh block for new assignments

example:

  1.  $names array('peter''nicole');
  2.  $tpl_name $tpl->get_block('name_block');
  3.  foreach ($names as $name{
  4.      $tpl_name->assign('name'$name);
  5.      $tpl->assign('name_block'$tpl_name);
  6.      $tpl_name->clear();
  7.  }




Tags:

since:  1.0.0
access:  public


[ Top ]

method display [line 139]

void display( )

displays the output

same as:

  1.  echo $tpl->get_content();




Tags:

since:  1.0.0
access:  public


[ Top ]

method get_block [line 216]

fxl_template get_block( string $blockname)

fetching a block for assignments



Tags:

since:  1.0.0
access:  public


Parameters:

string   $blockname   block name

[ Top ]

method get_content [line 122]

string get_content( )

finish rendering process



Tags:

return:  rendered template
since:  1.0.0
access:  public


[ Top ]


Documentation generated on Sat, 04 Sep 2010 13:57:09 +0200 by phpDocumentor 1.4.3