class

Liquid::Template

Inherits Reference / Object

Templates are central to liquid. Interpretating templates is a two step process. First you compile the source code you got. During compile time some extensive error checking is performed. Your code should expect to get some SyntaxErrors.

After you have a compiled template you can then <tt>render</tt> it. You can use a compiled template over and over again and keep it cached.

Example:

template = Liquid::Template.parse(source) template.render("user_name" => "bob")

Constructors

new

creates a new <tt>Template</tt> from an array of tokens. Use <tt>Template.parse</tt> instead

Source

Class methods

file_system
Source
file_system=(obj : Liquid::FileSystem)
Source
parse(source)

creates a new <tt>Template</tt> object from liquid source code

Source
register_filter(filter : Filter.class)

Pass a module with filter methods which should be available to all liquid views. Good for registering the standard library

Source
register_tag(name, klass)
Source
tags
Source

Instance methods

assigns
Source
errors
Source
instance_assigns
Source
parse(source)

Parse source code. Returns self for easy chaining

Source
registers
Source
render(context : Context, registers : Hash(Symbol, Type), filters : Array(Filter.class))
Source
render(environment, registers : Hash(Symbol, Type), filters : Array(Filter.class))
Source
render(context : Context, registers : Hash(Symbol, Type))
Source
render(context : Context, filters : Array(Filter.class))
Source
render(environment, registers : Hash(Symbol, Type))
Source
render(environment, filters : Array(Filter.class))
Source
render(context : Context)

Render takes a hash with local variables.

if you use the same filters over and over again consider registering them globally with <tt>Template.register_filter</tt>

Following options can be passed:

  • <tt>filters</tt> : array with local filters
  • <tt>registers</tt> : hash with register variables. Those can be accessed from filters and tags and might be useful to integrate liquid more with its host application
Source
render(environment)
Source
render
Source
render!(*args)
Source
root
Source
root=(root : Nil | Liquid::Document)
Source