Template Element Element

Home | Getting Started | API | Elements | Actions | Validators | Handlers | Configuration Options | Plugins | Mobile | Troubleshooting | About

Table of Contents

1 Template Element - #template {}

The template element allows you to specify html chrome for your page (header, footer, columns, etc.) while using a special placeholder syntax to call back to your page or any Erlang module.

To specify a placeholder in the html template file, use the form:

[[[Module:Function(Args)]]]

Module can be any module, or can be the atom 'page' to refer to the0 currently Nitrogen page. The function must return either one or more Nitrogen elements, an Erlang string, or an Erlang binary.

If the args are identifed like Erlang variables (capitalized first letter) such as MyArg1 (as opposed to a static value such as 5), then the template element will look in its bindings property for a matching element.

It's also possible to specify alias module references to other modules. For example, the default module alias is actually [{page, wf:page_module()}], which basically means "If you encounter page:function(Args), replace page with the current page's module."

Usage

#template { files="./priv/templates/myTemplate.html", bindings=[
  {'Binding1', binding1},
  {'Binding2', binding2}
]}

Attributes

file - (String)
Path to an html template file, relative to the directory from which Erlang was started.
bindings - (Bindings, as expected by erl_eval)
A list of variable bindings to be used for arguments specified in the template. Example: [{'MyArg1', "Hello"}, {'MyArg2', "World"}]
module_aliases - (proplist of {alias, actual_module} pairs)
When alias is encountered as the module of a Module:Function(Args) call, replace alias with actual_module.

See Also

Date: 2013-10-20 21:59:21 CDT

Author: Rusty Klophaus (@rustyio)

Org version 7.8.02 with Emacs version 23

Validate XHTML 1.0

Comments

Note:To specify code blocks, just use the generic code block syntax:
<pre><code>your code here</code></pre>


comments powered by Disqus