Class | Liquid::Template |
In: |
lib/liquid/template.rb
|
Parent: | 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 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')
DEFAULT_OPTIONS | = | { :locale => I18n.new |
error_mode | [W] | Sets how strict the parser should be. :lax acts like liquid 2.5 and silently ignores malformed tags in most cases. :warn is the default and will give deprecation warnings when invalid syntax is used. :strict will enforce correct syntax. |
profiler | [R] | |
resource_limits | [RW] | |
root | [RW] | |
taint_mode | [W] | Sets how strict the taint checker should be. :lax is the default, and ignores the taint flag completely :warn adds a warning, but does not interrupt the rendering :error raises an error when tainted output is used |
creates a new Template object from liquid source code To enable profiling, pass in profile: true as an option. See Liquid::Profiler for more information
Pass a module with filter methods which should be available to all liquid views. Good for registering the standard library
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
if profiling was enabled in Template#parse then the resulting profiling information will be available via Template#profiler
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