Fork me on GitHub

Quick Reference

Register for the wiki to improve our high level overview notes…

Zazen (zena’s textile markup)

Zafu (templating)

Zafu is fully XHTML compliant, so you may just use or write templates the same way you write html pages. But of course there is magic to make things much easier. In particular the “r:” tag (zena’s render tag).

<r:METHOD />

Each METHOD may require and accept specific attributes, but within zafu r:METHOD tags, and especially within the r:void tag that doesn’t do anything by itself, you may also add arbitrary rubyless code in do=’RUBYLESS-CODE’ attributes.

Design Helpers

You should browse the zafu Reference directly, but here are some pointers to prominently usefull ones.

Data Manipulation Widgets

These are nice, but they, or their defaults or documented examples, may need some fixing to work with current zena versions.

  • edit (“each” item or block)
  • checkbox (link creation)
  • toggle (“each” checkbox like relation creation)
  • swap Improved “checkbox” links (cycling attribute values)

Custom form creation is explained at HTML Forms with Zena. But for simple forms it is very easy to just use the defaults of these zena features:

  • add (button that shows hidden form)
  • form (can render a default form)
  • unlink (page: tags)

You can create an “edit” mode Zafu template for your page with forms and even include a javascript based editor (eg. MarkItUp!). You must be careful if the editor creates HTML though, because if the content will be saved as HTML this means it will be harder to render in non-html contexts (email, pdf, rss).

Data Helpers

Data Selection

  • query_parse : To provide powerful dynamic seach criteria (<,!, ..) in queries (compiled during runtime). Used with query that enters a custom, dynamically parameterized node context, where relying on the unknown method resolution and using context is not possible.
  • scope index creation may be required for some queries.
  • filter : Ajax form that updates parameters for a block, e.g. adjusting listings, selection queries and creation of (new) forms .

Data Analysis

Data Manipulation

  • new (object context)
  • default do='default' label='t' ... (set default parameters for sub elements)
  • form (renders a form that includes zena variables in hidden fields)
    • input (date,id,checkbox,hidden,...submit)
    • textarea
    • select
    • upload_field
    • captcha
    • form redirection: <input type='hidden' name='redir' value='#{zen_path(main, :mode =&gt; 'foo')}'/>
    • copying attributes:
      • <r:input type='hidden' name='v_text' value='[v_text] copy'/> copy predefined variable
      • <r:select name='text' nodes='letter_templates in site' attr='text' show='title'/> copy an attribute from selected node
      • <r:input type='hidden' name='copy_id' value='45'/> copy all attributes, copy_id is still undocumented (page: select)
  • link actions to destroy nodes and update blocks


(Also see the filters page.)

Pseudo Attributes

  • _id _ids suffix to refer to the ID(s) instead of title??? of the link target. Writes create or update the links.
  • link_id
  • store=’variable’ To save current context in variable.
  • set_… can also save the context in a variable (set_base='this').
  • node_name depreciated in favor of title?

node objects

  • <r:void do='this'/> returns #<Node:0x.....>
  • <r:void do='this_id'/> and <r:void do='main_id'/> returns nothing?
  • <r:void do=''/> returns the ID of the originaly renderd node context (mentioned in the browser).
  • <r:void do='id'/> and <r:void do='zip'/> return the id value of the current context that is incremented separately for each site (only reference?: testing again) Which one is depreciated???
  • <r:void do='parent_id'/> and <r:void do='parent_zip'/> respectively
  • <r:void do='start_node'/> the node the browser is still pointing regardless of ajax block reloads.

Using (URL) Parameters

For example, from a request with “&year=2000”:
  • <b do='params[:year]'/>
  • and <r:void do='params[:year]'/>
  • but <r:show text='#{params[:year]}'/>
    • Where #{} evaluates rubyless within a string, and params[:year] is the (url) parameter in rubyless (page: Select and having clauses in SQLiss).
      • In sqliss: ’"nodes where title like "%#{params[:f]}%"’ Here the qotation (“) is used to pass a string to the “like” method. The string has the wildcard character ”%” added to make like match more. (page: query_parse).



<r:void do='(0..params[:x].to_i).to_a'>
	<span do='each' join=', then ' do='this'/>


<ul do='%w{first_name last_name}'>
  <li class='#{this}' do='each' do='@node.eval(this)'/>

The %w{foo bar} is a ruby short cut for a whitespaced word array [“foo”, “bar”], and you can display a random property with “eval”.

The guideline is that you can use ruby syntax in zafu. For example, square brackets can be used to create a new array variable of elements: <r:set list='[]'>

Obsolete Syntax

  • Square brackets for variables as in where title like "[param:s]%" was old “toy parser” syntax (page: RubyLess)
  • The “v_” prefix to access virtual_attributes? where='v_title like "%[param:f]%"'
  • The “d_” prefix for dynamic attributes?

Common gotchas

The contexts you enter (e.g. with <r:posts>) are arrays. Therefore, to access node properties, you have to do=’first’ or do=’each’, or <r:first do='medhod-name'>, to get into the context of the first node in the list that the sqliss query returned, and use a ClassCondition to make the class properties accessible. Otherwise you may get a “method-name not found”, or the property seems to always be empty (nil). See bug51 and bug49. Other workarounds may be to use “this.method-name”, or create a template stub for the node class (in the dev_mode overlay).

Remember to limit queries with “limit 1” or limit=’1’, if you know there is only one record or you just need to fetch one. You can also use “find” :

<div do='friends' find='first'>
  ... context of a single node

In the absence of a “find” instruction, zafu uses the “arity” of the relation (“has_one” or “has_many”) as defined in the relation to determine the context to use (single element or array of elements).


HTML attributes

Found in rendered html, meaning and Uses?

data-z zena?
data-d default?