class Liquid::Template
- Liquid::Template
- Reference
- Object
Overview
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 render 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")
Defined in:
liquid/template.crConstructors
-
.new
creates a new Template from an array of tokens.
Class Method Summary
- .file_system
- .file_system=(obj : Liquid::FileSystem)
-
.parse(source)
creates a new Template object from liquid source code
-
.register_filter(filter : Filter.class)
Pass a module with filter methods which should be available to all liquid views.
- .register_tag(name, klass)
- .tags
Instance Method Summary
- #assigns
- #errors
- #instance_assigns
-
#parse(source)
Parse source code.
- #registers
- #render(context : Context, registers : Hash(Symbol, Type), filters : Array(Filter.class))
- #render(environment, registers : Hash(Symbol, Type), filters : Array(Filter.class))
- #render(context : Context, registers : Hash(Symbol, Type))
- #render(context : Context, filters : Array(Filter.class))
- #render(environment, registers : Hash(Symbol, Type))
- #render(environment, filters : Array(Filter.class))
-
#render(context : Context)
Render takes a hash with local variables.
- #render(environment)
- #render
- #render!(*args)
- #root : Liquid::Document?
- #root=(root : Nil | Liquid::Document)
Constructor Detail
Class Method Detail
Pass a module with filter methods which should be available to all liquid views. Good for registering the standard library
Instance Method Detail
Render takes a hash with local variables.
if you use the same filters over and over again consider registering them globally with Template.register_filter
Following options can be passed:
- filters : array with local filters
- registers : hash with register variables. Those can be accessed from filters and tags and might be useful to integrate liquid more with its host application