inversion

Templates

Inversion templates are the primary objects you’ll be interacting with. Templates can be created from a string via Template#new, or from a file with Template#load.

Template Options

You can set Inversion’s configuration options in a number of ways.

To set global options, Inversion supports the Configurability API, and registers itself with the templates key. This means you can either add a ‘templates’ section to your Configurability config, or call Inversion::Template.configure yourself with an object that can be passed to Hash#merge.

To set options on a per-template basis, you can pass an options hash to either .load or .new, or set them from within the template itself using the configure tag.

The available options are:

:ignore_unknown_tags
Setting to false causes unknown tags used in templates to raise an Inversion::ParseError.
Default: true
:on_render_error
Dictates the behavior of exceptions during rendering.
:ignore
Exceptions are silently ignored.
:comment
Exceptions are rendered inline as comments.
:propagate
Exceptions bubble up to the caller of #render.
Default: :comment
:debugging_comments
Insert various Inversion parse and render statements while rendering.
Default: false
:comment_start
When rendering debugging comments, the comment is started with these characters.
Default: "<!--"
:comment_end
When rendering debugging comments, the comment is finished with these characters.
Default: "-->"
:template_paths
An array of filesystem paths to search for templates within, when loaded or included with a relative path. The current working directory is always the last checked member of this.
Default: []
:escape_format
The escaping strategy used by tags such as escape and pp.
Default: :html
:strip_tag_lines
If a tag's presence introduces a blank line into the output, this option removes it.
Default: true