Solid (solid v1.0.0-rc.0)
View SourceSolid is an implementation in Elixir of the Liquid template language with strict parsing.
Summary
Functions
It generates the compiled template
It generates the compiled template
It renders the compiled template using a map with initial vars
It renders the compiled template using a map with vars
Types
@type error() :: Solid.UndefinedVariableError.t() | Solid.UndefinedFilterError.t() | Solid.ArgumentError.t() | Solid.WrongFilterArityError.t() | Solid.FileSystem.Error.t() | Solid.TemplateError.t()
@type errors() :: [error()]
Functions
@spec parse( binary(), keyword() ) :: {:ok, Solid.Template.t()} | {:error, Solid.TemplateError.t()}
It generates the compiled template
This function returns {:ok, template}
if successfully parses the template, {:error, template_error}
otherwise
Options
tags
- Override tags allowed during compilation. SeeSolid.Tag.default_tags/0
for more information on the default set of tags
It generates the compiled template
This function returns the compiled template or raises an error. Same options as parse/2
@spec render(Solid.Template.t(), map(), keyword()) :: {:ok, result :: iolist(), errors()} | {:error, errors(), partial_result :: iolist()}
@spec render(Solid.Parser.parse_tree(), Solid.Context.t(), keyword()) :: {iolist(), Solid.Context.t()}
It renders the compiled template using a map with initial vars
Options
file_system
: a tuple of {FileSystemModule, options}. If this option is not specified,Solid
usesSolid.BlankFileSystem
which returns an error when therender
tag is used.Solid.LocalFileSystem
can be used or a custom module may be implemented. SeeSolid.FileSystem
for more details.custom_filters
: a module name where additional filters are defined. The base filters (those fromSolid.StandardFilter
) still can be used, however, custom filters always take precedence.strict_variables
: iftrue
, it collects an error when a variable is referenced in the template, but not given in the mapstrict_filters
: iftrue
, it collects an error when a filter is referenced in the template, but not built-in or provided viacustom_filters
matcher_module
: a module to replaceSolid.Matcher
when resolving variables.
Example
fs = Solid.LocalFileSystem.new("/path/to/template/dir/") Solid.render(template, vars, [file_system: {Solid.LocalFileSystem, fs}])
@spec render!(Solid.Template.t(), map(), keyword()) :: iolist() | no_return()
It renders the compiled template using a map with vars
Same options as render/3