 |
Flat-Frog - the faster compiling PHP template engine |
What is Flat-Frog?
Flat-Frog has many advantages over other template engines, as well as a few disadvantages.
- Flat-Frog is a stripped down version of another template engine and thus is extremely fast, yet very similar to other template engines.
- Flat-Frog uses most of the same basic syntax as some other template engine, making it relatively easy to port template files from other template engine and to quickly learn how to use it.
- Flat-Frog's variable syntax, specifically variables in double quotes and concatentation, is designed to imitate PHP's, making variable usage intuitive for beginners who are used to programming in PHP.
- Flat-Frog introduces the new
switch
and for
tags, which have identical functionality to PHP's switch
and for
functions, respectively.
- Flat-Frog compiles all template files for speed, making script start-up faster. All compiled files are saved for faster loading on the next load.
- Flat-Frog will also optionally save a cached version of templates, thus bypassing any compiling or execution, as it will load static pages precompiled and assembled, offering significant speed increases.
- Flat-Frog supports config files and variables and will compile config files for speed, too!
Flat-Frog has a few disadvantages, though.
- Flat-Frog does not have all the features of other template engine, such as pre/post/output filters,
include_php
tag, section
tag, security features, and error handling.
- Flat-Frog plugins and templates are not compatible with other template engines without at least a little modification.
- Flat-Frog has no support for objects/classes. This was removed for speed. (Besides, classes in PHP4 are slow as hell to begin with.)
- Flat-Frog has no support for template resources. This was removed for speed. (Besides, who wants to load a template from a database. That's also slow as hell.)
Flat-Frog was designed from the ground up to be fast. It has acheived that goal.
What you see here is the work of Paul Lockaby. However, while more than 75% of the code in this template engine has been rewritten, a bunch of that other 25% and a lot of organization has been directly derived from Smarty - the compiling PHP template engine for PHP. Smarty template engine was originally programmed and is still maintained at the aforementioned website by Monte Ohrt and Andrei Zmievski.
Serge Gilette as taken upon the maintenance and evolution of Flat-Frog since january 16th 2006.
At the moment I know of no bugs. Usually when I find one, I squash it as soon as possible. Let me know if you find one and I'll fix it, too.
These are things that I should have done before I released it, but that I put off to do until after I released the code.
- Comments inside of comments do not get parsed properly. (ex:
<%* a comment <%* another comment *%> *%>
will be displayed as *%>
)
- Massively better error handling (read: there is none thus far).
- March 30th, 2006 - Version 2.2.13
- Added the virtual function
- Added the name argument in foreach
- January 17th, 2006 - Version 2.2.12
- Fixed a typo in html_image. (Thanks to Michael Klein.)
- Fixed a bug in clear that was a result of a typo.
- Changed all attributes to lower case in the html_* plugins to compatible with XHTML. (Thanks to Michal Durys.)
- Fixed a bug in html_checkbox and html_textbox that resulted in incorrect rendering of their HTML elements.
- Fixed a bug in the handling of Samba paths on Windows servers. (Thanks to Ara Anjargolian.)
- Updated some errors in the documentation.
- Fixed a bug in html_options where there was a typo. (Thanks to Michael Klein.)
- October 10th, 2005 - Version 2.2.11
- Updated all of the plugins to follow a more standard code base and to properly escape strings before being passed to the template. (Thanks to Ara Anjargolian and Michael Klein.)
- Fixed a bug in _rm_dir that prevented it from removing non-cache groups and compiled pages correctly.
- Fixed a bug in _get_plugin_dir that referred to a hardcoded directory separator. (Thanks to Michael Klein.)
- Fixed a warning in _build_dir. (Thanks to Michael Klein.)
- Fixed a bug where error level reporting was being returned to normal prematurely. (Thanks to Axel.)
- Changed the required stack from a numerical array to an associative array to avoid using array_unique in order to remove duplicate plugins from the list. (Thanks to Axel.)
- Fixed a typo in _parse_function that would throw errors in some situations.
- August 7th, 2005 - Version 2.2.10
- Updated documentation to fix errors in the documentation for count. (Thanks to Georg Gretz.)
- Fixed a bug in _is_cached that would result in an error if cache groups were to be used. (Thanks to Hahl Laszlo and Michael Klein.)
- Removed the 777 umask from the cache group builder. Folders created in the cache directory to represent cache groups will now use the same permissions as the parent directory.
- Added the php tag to the compiler to allow for putting PHP directly into the template. To get to the variables assigned to the template, you can use the get_vars function to get variables from the PHP code. (Thanks to "Panama Jack".)
- June 29, 2005 - Version 2.2.9
- Fixed a bug in class.compile.php where assign didn't work. (Thanks to Georg Gretz.)
- Updated documentation to actually refer to the count modifier.
- Changed bbcode2html so that it uses <pre> to surround blocks of code.
- February 26, 2005 - Version 2.2.8
- Changed the newline in each file back from \r\n to just \n, thus saving a few bytes and making it more "Unix"-like.
- Fixed a bug where modifiers that didn't exist but began with a number ended up being concatenated to the end of the variable they were modifying.
- Fixed bug in if-then statements where variables with a number in them were parsed incorrectly.
- Fixed any known variable problems involving numbers in the variable name.
- February 14, 2005 - Version 2.2.7
- Fixed a bug that fell into the place somewhere along the line that caused modifiers with digits in them to be parsed incorrectly.
- Added html_hidden plugin.
- December 11, 2004 - Version 2.2.6
- Fixed a bug where variables of 1 character were being misinterpreted as function calls and thus throwing errors when the function was not found. (Thanks to Ara Anjargolian.)
- Added more special cases to if-then statements to accomodate for errors introduced in 2.2.5 and 2.2.4 with the template function changes. Specifically, the changes were adding the case-insensitive values "true", "false" and "null". (Thanks to Ara Anjargolian.)
- October 30, 2004 - Version 2.2.5
- Fixed a typo in the for function that resulted in the stop condition being changed if the step condition was not present.
- Fixed a typo in the switch function that resulted in it not working at all. (Thanks to user ximian on the Yellow Duck forums.)
- Template functions will not work in if-then statements. Almost all PHP functions will. Those that pass the function_exists test will, as well as empty, isset, and unset.
- October 15, 2004 - Version 2.2.4
- Modifiers can now be placed on variables in if-then statements, but functions in if-then statements will now throw an error as they should not be used in this context. (Thanks to Jacquot Frederic.)
- Added the values/output variables to html_options. (Thanks to Ara Anjargolian.)
- Fixed a bug in for that prevented the use of variables when assigning a starting and stopping point. (Thanks to Tim Green.)
- Updated the template code to use the more compatible <?php instead of <?. (Thanks to Pieter Claerhout.)
- September 16, 2004 - Version 2.2.3
- Fixed an bug in the _is_cached function that would result in incorrect cache usage.
- Added the urlencode modifier to the standard distribution.
- August 3, 2004 - Version 2.2.2
- IT IS VERY IMPORTANT THAT YOU CLEAN OUT YOUR COMPILE AND CACHE DIRECTORIES AFTER THIS UPGRADE!
- Another error in _is_cached() is now resolved. (Thanks to Ara Anjargolian.)
- Compiled and cached template MD5s are now stored with the full template directory path in them to allow for storing templates in different template directories. (Thanks to Pieter Claerhout.)
- Compiled files are now prefixed with a 'c_' when saved to allow compiled and cached files to be stored in the same directory. (Thanks to Pieter Claerhout.)
- July 31, 2004 - Version 2.2.1
- IT IS VERY IMPORTANT THAT YOU CLEAN OUT YOUR COMPILE AND CACHE DIRECTORIES AFTER THIS UPGRADE!
- My attempt at making cache files check included files for changes failed previously. Now it works.
- July 31, 2004 - Version 2.2.0
- IT IS VERY IMPORTANT THAT YOU CLEAN OUT YOUR COMPILE AND CACHE DIRECTORIES AFTER THIS UPGRADE!
- If a file was cached and had
includes
and the includes changed, the cached file wouldn't change. Now if an included file changes the cache will be regenerated.
- IMPORTANT! Removed support for compile_ids. This is a big one as it changes the syntax of all calls to
display
and fetch
and requires regeneration of all existing template files. (Thanks to Ara Anjargolian.)
- Fixed a bug where in some cases, not having a trailing slash on your template directory name would result in an error when calling
is_cached
. (Thanks to Pieter Claerhout.)
- Empty templates no longer generate an error.
- PHP tags are now escaped so that you can create XML templates.
_get_dir
now correctly checks for a trailing slash using DIRECTORY_SEPARATOR instead of '/'. (Thanks to Pieter Claerhout.)
- July 18, 2004 - Version 2.1.2
- Fixed custom function parsing, which has apparently always been broken.
- Paths now work in Windows. Didn't work because of a quoting bug. Now use single quotes instead of double quotes.
- Can now pass an object method as a custom function/block/modifier.
- Removed "compiler functions" because I think they're a pain to maintain.
- July 14, 2004 - Version 2.1.1
- Fixed concatenation problems.
- Implemented a new 'count' modifier that when used with the '@' will return the number of elements in the array it modifies.
- Fixed plugin modifier routines to correctly map to arrays.
- February 7, 2004 - Version 2.1.0
- Really fixed the
in_array
bug in get_config_vars
this time. Honestly.
- Fixed a bug where if a modifier was missing it would not give the name of the modifier missing but instead give some crap. Thanks to Ryan Johnson for catching this one.
- Added the legacy option 'item' to
foreach
.
- Fixed the broken functionality of
$force_compile
as a result of the 2.0.0 release. :(
- Fixed a bug in
class.config.php
that kept it from creating arrays if $config_overwrite
was enabled and made appropriate changes to class.template.php
to accomodate this change in the compilation step. This new fix requires PHP 4.2.0, however.
- Made it such that if you have an array of config variables you can actually refer to them in your template using a similar syntax to an array of variables. They syntax looks like this:
#foo[$bar]#
.
- Variables can no longer begin with an integer.
- The following syntaxes actually work.
$foo[$bar]
, $foo[#bar#]
, #foo[0]#
, #foo[$bar]#
, #foo[#bar#]#
. Note that you cannot have $foo[#bar[0]#]
or anything like that (i.e. an array in an array) because I don't think it can be done ad inifinitum. Anyone who thinks differently can submit some code.
- January 20, 2004 - Version 2.0.1
- Fixed a bug with
for
that would cause it to not work at all.
- Fixed a bug with
for
that required the step
option. Now step
defaults to '1'.
- Changed
in_array
in get_vars
and get_config_vars
to isset
because the former didn't seem to work, and I just noticed that.
- January 15, 2004 - Version 2.0.0
- Fixed major bug with
clear_compiled
that would cause the script to not remove all compiled templates.
- Added the following variables to be set by the user:
$cache
- if set to 'true', pages will be cached for speed.
$cache_dir
- where the cached files will be stored on the filesystem.
$cache_lifetime
- how old the cache can be before it gets flushed.
- Added the following functions for use by the user:
is_cached($file, $compile_id = null, $cache_id = null)
- will see if the specified file has a cached copy available.
clear_cached($file = null, $cache_id = null)
- will clear the cache for the specified file and cache id, or if neither are specified, the entire cache.
- Modified the following functions for use by the user:
display($file, $compile_id = null, $cache_id = null)
- now has the optional $cache_id
parameter.
fetch($file, $compile_id = null, $cache_id = null) - now has the optional $cache_id
parameter.
- Caching was added for templates. Cache lifetimes are specified by the user for each template. Cache lifetimes are also inherited from the calling template, so if you use an
include
, the included file will have the same cache lifetime as the calling template. The default cache lifetime is zero seconds, which is the same as not having a cache.
- Cache groups are handled in the same fashion as compile groups.
- Inserts are not be cached and are fetched with each invocation of a cached template. Required a change to the compiler that would check to see if the the page was being cached and then store the insert data different. So basically, to copy the Flat-Frog people, I took an MD5 hash of 'Flat-Frog' (or was it 'Flat-Frog'... I can't remember) and surrounded the insert information in that and then replaced it using a built-in post-filter.
- Rewrote
_rm_dir
and _destroy_dir
and clear_compiled
code to be a little cleaner and better (and in some cases actually work).
- Removed "support" for running the installation without compilation. Support was spotty and I can't figure out why anyone would use it that way anyway.
- Rewrote
fetch
code to handle caching, added a _fetch_compiled
function, thus making it so that fetch
only receives the completely compiled code, not each individual template. Also required a change in the compiler to implement this change.
- Added a new
for
function that will loop through a block of code from start
to stop
, and skipping step
integers each time. Identical in functionality to PHP's for
loops in PHP. An optional value
argument will assign the current position of the foor loop to the variable specified (by way of value=var
).
- Fixed bug in compiler where a value of "0" was the same as an empty value.
- Fixed a bug in
foreach
error checking.
- Heavily modified the way
inserts
work in order to allow them to be non-cacheable.
- Fixed the
plugin_dir
retrieval so that it will work via relative or absolute paths. For instance, if your plugin directory is a sub-directory of your bin directory then it will recognize that, but if it is somewhere else, it will also recognize that.
- Fixed
config_load
compiling problems :\ where no quotes were put around strings and such.
- Fixed a spacing bug that would insert stupid newlines all over the place, where they didn't belong.
- Miscellaneous fixes and speed-ups here and there.
- Reorganized and wrote some new documentation.
- Removed the
$display
parameter for fetch
and instead just made display
function echo the fetch return.
- December 14, 2003 - Version 1.1.16
- Added a boolean option into
html_checkbox
so that if you pass "true" or "yes" or "on" as the checked
value, it will be checked. Additionally, it will still be checked if value
is equal to checked
.
- Fixed a bug with
class.config.php
that would read commented variables in.
- Changed the method with which files are read in to use
file_get_contents
which is supposedly faster than using fread
.
- July 27, 2003 - Version 1.1.15
- Removed the
spacify
modifier from the distribution.
- Updated the docs some more. They are basically done now, but I may make changes later to update them.
- Included the docs with the distribution.
- Modified a bunch of the
html_*
functions to be more standards complian (i.e. quotes around attribute values).
- Modified
html_options
and removed the values and output attributes.
- July 25, 2003 - Version 1.1.14
- Made
html_textbox
be HTML 4.01 Strict compatible
- Fixed a bug in
class.config.php
that would mess up a config value if it contained a # (pound).
- July 17, 2003 - Version 1.1.13
- Fixed a bug with
elseif
.
- Fixed a bug with assigning variables using the
assign
operator.
- July 15, 2003 - Version 1.1.12
- Added
html_options
to plugins folder.
- July 14, 2003 - Version 1.1.11
- Fixed incredibly stupid and embarrasing bug in
_run_insert
that prevented inserts from working at all. Way to go me for not testing them...
- July 13, 2003 - Version 1.1.10
- Fixed bug where compilation would crash if the the template file was empty.
- Made it so that E_NOTICE errors will not come up during template execution.
- July 4, 2003 - Version 1.1.9
- Added functions
assign_config
and clear_config
to facilitate assigning configuration variables. I know that this defeats the purpose of configuration variables, but for my needs, I want it like this.
- Fixed stupid bug in the assigning of an array of values, also added check to not allow for numeric variable names.
- Fixed \$ bug in
foreach
compilation.
- July 3, 2003 - Version 1.1.8
- Modified
class.template.php
and class.compiler.php
to store the compile_id as a class variable.
- Forced compiled included templates to be saved in the same compile id folder as the template that included them.
- Fixed bug in
class.config.php
where it would read the first section in the file twice, once as the section name and once as the "globals" section. Fixed this by inserting a space at the beginning of the file after it is read into memory.
- This time I actually put all of the necessary files into the zip file to be released. I don't know what was up with that!
- July 2, 2003 - Version 1.1.7
- Fixed bug where an error come up on E_ALL because a variable wasn't initiated.
- June 22, 2003 - Version 1.1.6
- Changed the special _TPL vars from referencing $GLOBALS to referencing the $_ super-globals.
- Fixed
include
so that it stored the included files inside of the same subdirectory as the original file in the compile directory.
- Fixed the
_build_dir
code to not create any directories if compile = false
.
- Forced
clear_compiled
to exit without doing anything if compile = false
.
- Removed a debugging
echo
statement from _rm_dir
.
- Fixed bug in compilation and the compilation path of
config_load
.
- Finished some more plugins,
capture
, cycle
, counter
, and html_radio
.
- June 22, 2003 - Version 1.1.5
- Removed support in config files for single quotes around values. Can still use double quotes and keywords like true/false, yes/no, and on/off
- Changed modifiers back to the
tpl_
syntax so as to avoid confusion regarding any support for modifiers.
- Moved _syntax_error *back* to
class.template.php
and renamed it to 'trigger_error'
- Wrote a bunch of new and copied a bunch existing plugins to be included with the Flat-Frog distribution.
- Fixed multiple bugs with the modifier usage and plugin inclusion.
- Updated documentation to include a tiny bit more information on config files, functions, and modifiers. Documentation is still sparse.
- Took
config_load
and put it into class.compiler.php
instead of in the plugins folder.
- Wrote in three new functions to allow for compile groups to be made. Also will allow for cache groups to be made when the time comes.
- Moved the compile object into a class-variable instead of a function variable, to execution speed on multiple display/fetch calls.
- June 20, 2003 - Version 1.1.4
- Included a bunch of plugins with the distribution.
- Added support for config files, config vars and included the config_load function in
class.template.php
- June 18, 2003 - Version 1.1.3
- Changed plugin nomenclature to be entirely compatible with some other templating engine. This means that modifier, function, block, and compiler plugins written for some other templating engine can be used with Flat-Frog.
- Fixed a bug in _run_modifier and _parse_modifier.
- Added a _require_stack variable into the compiler so that files that need to be included will be included dynamically and automatically. This also puts more of the error-checking into class.compiler.php, that is when I begin writing error-checking routines.
- Added a regular expression into the compiler that will remove all unncessary opening and closing PHP tags.
- Fixed a bug in _compile_arguments
- Added 'force_compile' option (mostly for my testing :)
- June 17, 2003 - Version 1.1.2
- Fixed some embarrassing bugs in the template compiler regarding modifiers and missing functions.
- Made class compiler extend class template.
- Removed modifier specific references to the _plugin_exists function.
- Updated documentation to include some comments on variable modifiers.
- Allowed functions inside of IF-THEN statements.
- Added to the TODO list, perhaps someday I'll begin taking off of it, who knows.
- June 16, 2003 - Version 1.1.1
- Removed _syntax_error and _fatal_error from class.compiler.php
- When the script doesn't find the specified template file, it will just die and say the name of the file it couldn't find.
- Forced the compiler to check for the existence of plugins instead of the displayer (thus allowing me to remove _syntax_error from class.compiler.php).
- June 15, 2003 - Version 1.1.0
- Seperated the compiler from the displayer.
- Add option to save compiled files. This coupled with the compiler seperation gives me a two to three times speed increase.
- June 12, 2003 - Version 1.0.0
Home