Languages

PHP MicroTemplate 1.0.0

By: Mtpl
Version: 1.0.0

Downloads:0

Hits:1003

SourceNO

Link Broken:Report It!

Package:Without source

Price:$0

More info Download

Description

This class provides an extremely fast, lightweight templating system for HTML and other text-based documents. Like FastTemplate and its many clones, MTPL supports nested blocks and looping. However, the entire implementation is done without a single regular expression. The PHP interpreter is leveraged for its built-in variable interpolation, and explode() is used to separate block markers from content using a simple delimiter. As a result, the overhead of reading and parsing template files is minimal. This should eliminate the need for a cache and improve the overall performance of template- driven sites. Since PHP's dollar sign notation (ie. "$var") is used to identify content placeholders, it is sometimes necessary to escape dollar signs in your template (ie. "$$amount"). You can use arrays with the form $array[element]; just don't quote the index. $array['element'] or $array["element"] will generate PHP parse errors due to the way PHP evaluates hashes in a string context. For the same reason, multi-level arrays will not work ("$a[b][c]" becomes the value of $a[b] followed by the literal text "[c]"). Global variables can be accessed using the usual $GLOBALS[] array method. For instance, to get the script URL, you can use $GLOBALS[PHP_SELF]. There are a few other differences. The assign() method found in most PHP template classes is gone. Instead, all assigned variables must be provided as a hash that is passed to the parse() method. Since in almost every single case a series of assign()'s is done followed by a single call to parse(), this eliminates some redundancy. It also provides a more strict scoping to template variables which should result in scripts that are easier to debug. Two variations on parse() exist: parseLoop() and parseOut(). parseLoop() takes a list of hashes instead of a single hash of variables to assign and calls parse() on the same block for each. This allows you to populate tables and drop-downs without the need to write loops into your code. parseOut() iteratively calls parse() for a given block and each of its parents in order. For instance, parseOut('main.section.sub') will parse 'main.section.sub', then 'main.section', then 'main'. Both of these methods should reduce the amount of code you need to write for typical operations. You will also notice that there is no out(), text(), or print() method. Rather than holding onto all output internally, the parse() and related methods return the resulting output. To output the result of a parse operation, simply: echo parse(...); PHP's native error handling is used for all errors and warnings. In addition, by adding "error_handling(E_ALL);" to your scripts, the PHP interpreter will warn you about any uninitialized template variables. Granted, the error messages are a bit odd (since interpolation is done inside of an eval()), but this can be a good way to track down typos.

Language: PHP

Related:

Class - Php - Php Classes - Php Template - Template - Template Class

User Reviews:

Write Review *
Your name *
Email *
(Your comments will be reviewed by our staff before they are posted)
Rate this product *
Captcha Image
Enter code from image *

 

Related:

php pdf class 0.5

This is a comprehensive class for PHP which generates PDF documents.

By: Bpdf Homepage

Freeware

php-arapi library 0.3.2

The php-arapi library is an extension for PHP4 and PHP5 for integration to BMC Remedy AR System.

By: Php-arapi Homepage

Freeware

PHP Class Collection 1.0

This project provides different classes written in PHP 5.

By: Php-classes Homepage

Freeware

MySQL php class 1.0

This class is a wrapper to access MySQL databases.

By: download.softpedia.ro Homepage

Freeware

Bobo PHP DB Class 1

It can establish a connection to a MySQL database server host, execute SQL queries and retrieve the results into arrays.

By: download.softpedia.ro Homepage

Freeware

PHP Template SKOR 1.0

PHP Template SKOR : The class can assign variable values.

By: template.ecoware.de Homepage

Freeware

OO Template Class 0.2

An object oriented template class you can use in your own programs.

By: net-track.ch Homepage

Freeware

Whedimer Template Class 1.0

A simple, efficient template class with a small tutorial to get you started using it.

By: whedimer.com Homepage

Freeware

PHP Template Class 0.5

PHP Template Class is a simple template class to use with PHP scripts and is a very useful tool for PHP programmers. Complete documentation...

By: Oliver Hitz Homepage

Freeware

Simple Turtle PHP Template 1.0 Beta

Simple Turtle PHP Template is a simple, small, fast and quick to use function that helps separate between the logic and presentation layers in PHP...

By: Elias Homepage

Freeware