Fork me on GitHub


An article by Gaspard Bucher

Zafu is the scripting language used to build the templates in zena.

This documentation is not as complete and up to date as the template language itself, but it should get you going. Please ask and improve the documentation if you need some information that is missing.


Each website / intranet has it’s own workflows, needs it’s own design and handles specialized information. The templating language zafu is at the center of all this machinery.

The language was created with the following goals in mind:

  • xhtml : so templates can be viewed in web browsers.
  • type less : less to write means less errors and faster results.
  • describe : the language should describe the actions and real content it is displaying.
  • ajax : create application like functionalities as easily as you write html.

If you are looking for introductory material, you might be interested in the tutorials on zafu.

The documentation is organised by functionality (ajax, forms, context, display, etc). You can use the live search above the menu to quickly find a tag.

rubyless, SQLiss

We make extensive use of both of these tools in zafu. When you write code such as:

<h1 do='title'/>

the zafu compiler sees a method called “title”. It will try to resolve this method using the following scopes:

  1. execute “r_title” in the parser (existing render tag)
  2. consider as rubyless
  3. consider as SQLiss
  4. consider as a property (use show method)
  5. all above failed: error

These evaluation rules are true for methods. When you enter arguments for methods, these are always considered as text. However, you can evaluate rubyless code in many arguments by using #{}. For example:
<p do='link' anchor='#{name}'/>. Beware that link and form are exceptions to this rule.

When compiling RubyLess code to ruby, a safe method is searched in the following places:

  1. in current scope’s object class (think self in ruby)
  2. in the helpers
  3. by prefixing with the current object (change “foo” into “foo(node)”)

RubyLess resolution

When the compiler tries to find if a particular method exist and is safe, arguments are part of the signature. For example, <h3 do='foo' bar='baz'/> is searched as a safe method with the signature ['foo', {:bar => String}] .

All hash parameters declared with [method, {key => value, key2 => value}] are optional. This means that the method declaration for ‘foo’ above will also match <r:foo/>


In Zafu, everything that follows ’//!’ is considered to be a comment. If you really need to have ’//!’ in your template, you can write <r:show text='//!'/>.

  <ul do='images in project'> //! find all images in the current project
    <li do='each' do='link'/> //! create a link for each image