Call for evaluation and discussion

0 views
Skip to first unread message

mindplay.dk

unread,
Feb 25, 2008, 4:40:50 PM2/25/08
to php-outline
After about a year of working on this template engine (and at least a
year of pondering prior to writing the first code), I have decided to
make Outline available to the general public.

This template engine was designed to be fast and light. It is quite
different from most other template engines - rather than trying to
build a completely new template engine on top of php (which itself
arguably is a template engine), Outline merely tries to leverage and
simplify php itself.

The resulting syntax is shorter, simpler and more legible than that of
a lot of the larger template engines, and a lot more simple and
legible than pure php syntax.

Templates are compiled, so there is practically no overhead from the
engine itself, which is less than 200 lines of code. The entire system
(including cache engine, compiler and plugins) is less than 1000 lines
of code.

The template compiler performs basic structural validation, to ensure
that commands and blocks are nested and closed properly.

However, the parts of the syntax that is borrowed from php, are not
validated in any way - this means you will get a php error message if
you make a mistake. Since line-numbers in template sources and
compiled templates always match 1:1, this is not usually a problem -
an error in line 50 in "compiled/something.php" just means you made a
mistake in line 50 in "templates/something.html".

Also, no attempts to implement any kind of "security" is done - you
are not restricted from doing anything at all; you can access any
global variable, access any variable in the scope from which a
template was loaded, call static methods on loaded classes, call any
php function you wish, and so on.

If you follow any modern development pattern, such as MVC, you won't
do that, of course ;-)

But this makes Outline a template engine for closed teams of
developers and template designers - not a template engine for which
you can allow untrusted guests to edit or upload their own templates.

Anyway, feel free to examine the code and comment on it!

My next priorities are:

1. Upgrading the code to php 5 - currently, all methods and vars are
public.
2. Implementing support for templates in UTF-8 format.
3. Refining various parts of the code and (especially) the plugin
system.

That's all for now... :-)

mindplay.dk

unread,
Mar 11, 2008, 6:37:50 PM3/11/08
to php-outline
Well, this didn't trigger much response yet ;-)

I have been busy this weekend, and have basically rewritten the
compiler. The new compiler is more structured - it uses a plugin-based
architecture with more generic support for tags and block-tags, and
for most blocks now implements nesting-checks centrally.

The new parser supports opening/closing brackets with multiple
characters, and is designed to support UTF-8.

It is fully PHP5 using scope declarations, exceptions, etc.

Before I can release this, I still need to port the core commands from
the old compiler, and upgrade the engine and cache classes to full
PHP5 OOP.

It remains small and light by design ~ 300 lines for the compiler, and
the ported core commands should now be considerably smaller and
simpler.

Some speed has been sacrificed to ensure PHP6 compatibility in the
future (e.g. substr() instead of {index} operators) and to support
multibyte character sets. Speed is less of a concern here, since
templates are only compiled on change anyway...
Reply all
Reply to author
Forward
0 new messages