Flott - Floris Tolle Templates

This is ruby templating system with some unique features.

Installation

Use rubygems and just type:

gem install permutation

Usage

If you want to play with the parser it's best to use the Flott method:

Flott('1 + 1 = [=1 + 1]') # => "1 + 1 = 2"

However if you want to take advantage of the directory tree walking and inclusion features, you have to use actual files:

If two template files are stored in the current directory. One file "header":

Hello [=@name]! And one file "template": [^header-]

Hello [=@name]!

[for i in 1..6 if i % 2 == 0-] Hello [=@name]! [else-] Hello [=@name]! [end end-]

The parser can be used like this fp = Flott::Parser.from_filename('template') env = Flott::Environment.new env = "Florian" fp.evaluate(env)

Or this: puts Flott.string_from_file(filename, :name => "Florian")

You should also take a look at the other convenience methods in the Flott module.

The output is created by including "header" into "template" with the [^filename] syntax. [!@name] is a shortcut for [print @name] while [=@name] first calls Flott::Parser.escape on @name. It's also possible to just print or puts strings.

Note the use of the assignment to the instance variable @name before executing the template. The state passed to Parser#evaluate as an environment and can be referenced in the template itself with [=@name].

After execution the output is:

Hello Florian!

Hello Florian!

Hello Florian! Hello Florian! Hello Florian! Hello Florian! Hello Florian! Hello Florian!

Author

Florian Frank mailto:[email protected]

License

This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation: www.gnu.org/copyleft/gpl.html