View Source Solid (solid v0.16.0)
Main module to interact with Solid
Summary
Functions
It generates the compiled template
It generates the compiled template
It renders the compiled template using a map with vars
It returns the rendered template or it raises an exception with the accumulated errors and a partial result
Types
Functions
@spec parse(String.t(), Keyword.t()) :: {:ok, %Solid.Template{parsed_template: term()}} | {:error, %Solid.TemplateError{ __exception__: true, header: term(), line: term(), message: term(), reason: term() }}
It generates the compiled template
This function returns {:ok, template} if successfully parses the template, {:error, template_error} otherwise
Options
parser- a custom parser module can be passed. SeeSolid.Tagfor more information
@spec parse!(String.t(), Keyword.t()) :: Solid.Template.t() | no_return()
It generates the compiled template
This function returns the compiled template or raises an error. Same options as parse/2
@spec render(%Solid.Template{parsed_template: term()}, map(), Keyword.t()) :: {:ok, iolist()} | {:error, [errors()], iolist()}
@spec render( list(), %Solid.Context{ counter_vars: term(), cycle_state: term(), errors: term(), iteration_vars: term(), matcher_module: term(), vars: term() }, Keyword.t() ) :: {iolist(), %Solid.Context{ counter_vars: term(), cycle_state: term(), errors: term(), iteration_vars: term(), matcher_module: term(), vars: term() }}
It renders the compiled template using a map with vars
Options
file_system: a tuple of {FileSystemModule, options}. If this option is not specified,SolidusesSolid.BlankFileSystemwhich raises an error when therendertag is used.Solid.LocalFileSystemcan be used or a custom module may be implemented. SeeSolid.FileSystemfor more details.custom_filters: a module name where additional filters are defined. The base filters (thos fromSolid.Filter) 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_filtersmatcher_module: a module to replaceSolid.Matcherwhen 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.t()) :: iolist()
It returns the rendered template or it raises an exception with the accumulated errors and a partial result
See render/3 for more details