Archive for the 'template-engine' Category

10 lines implementation of PHP template engine

November 4th, 2007

PHP provides the following functions.

extract($array) — import associated array as local variables. include($filename) — read PHP file and evalue it.

Using these functions, you can get your own PHP template engine in 10 lines. The following is an example.

Why Smarty is too slow?

November 3rd, 2007

Smarty Template Engine is the most popular and widely used template engine for PHP. It is believed that Smarty is fast because it compiles templates into PHP code, but it is not true.

I have tried a simple benchmark program to measure speed of Smarty and PHP include() function. The result shows that PHP include() function is more [...]

ActionView is Not Beautiful

October 19th, 2007

From Making Rails Better - ActionView Needs a Makeover:

the internals of ActionView are ugly.

I think so very strongly. View-layer of Ruby on Rails depends on ERB tightly. Rails provides API for other template engine, but it is too poor to make other template engine to be the same position in Rails as ERB.

30 Lines Implementation of eRuby

October 9th, 2007

eRuby is a specification to embed Ruby code (expression or statement) in any text file. There are thee implementation of eRuby:

ERB (pure Ruby, most popular and included in Ruby 1.8) eruby (implemented as C extention) Erubis (pure Ruby, very fast and extensible)

Using pattern matching, it is easy to implement eRuby. The following is a complete eRuby implementation (named TinyEruby) [...]