10 lines implementation of PHP template engine 

Filed under: php, template-engine on Sunday, November 4th, 2007 by kwa | No Comments

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.

Read the rest of this entry »

Why Smarty is too slow? 

Filed under: php, template-engine on Saturday, November 3rd, 2007 by kwa | No Comments

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 than three times faster than Smarty.

Why Smarty is so slow? Because the PHP code compiled by Smarty is not efficient. The following example shows Smarty template code and compiled PHP code.

Read the rest of this entry »

pyTenjin 0.6.1 released 

Filed under: product, python on Tuesday, October 23rd, 2007 by kwa | No Comments

pyTenjin 0.6.1 has been released.

pyTenjin is a fast and full-featured template engine based on embedded Python. You can embed any Python statements and expressions in your text file. pyTenjin converts it to Python program and evaluate it with context data.

  • [Enhancements]
    • Benchmark script (benchmark/bench.py) is rewrited.
    • Benchmark supports Genshi, Mako, and Templetor.
    • Add examples.
  • [Bugfix]
    • Typo in User’s Guide is fixed.

ActionView is Not Beautiful 

Filed under: ruby, template-engine on Friday, October 19th, 2007 by kwa | No Comments

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 

Filed under: ruby, template-engine on Tuesday, October 9th, 2007 by kwa | No Comments

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) which contains only 30 lines.

Read the rest of this entry »

Erubis 2.4.1 released 

Filed under: product, ruby on Monday, October 8th, 2007 by kwa | No Comments

I have released Erubis 2.4.1 at 2007-09-25.
This is a bug-fix release.

You can see details about fixed bugs and changes in CHANGES file.