Warning: some features highlighted on this page are not yet available in the stable version of zena.
introduction
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, pseudo sql
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:
- execute “r_title” in the parser (existing render tag)
- consider as RubyLess
- consider as pseudo sql
- 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}'/>.
When compiling RubyLess code to ruby, a safe method is searched in the following places:
- in current scope’s object class (think
selfin ruby) - in the helpers
In the example above, the compiler matches “r_title”. In the example below it simply displays the version’s title (matching ‘version’ in class Node and ‘title’ in class Version):
<h1 do='version.title'/>
Other ways to do the same:
<h1 do='v_title'/>
<h1><r:version><r:title/></r:version></h1>
<h1><r:version do='title'/></h1>
<h1><r:eval>version.title</r:eval></h1>
<h1 do='eval'>v_title</h1>
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='title' actions='all'/> is searched as a safe method with the signature ['title', {:actions => String}].
All hash parameters declared with [method, {key => value, key2 => value}] are optional. This means that the method declaration for ‘title’ above will also match <r:title/>