Solid (solid v0.10.0) View Source

Main module to interact with Solid

iex> Solid.parse("{{ variable }}") |> elem(1) |> Solid.render(%{ "variable" => "value" }) |> to_string "value"

Link to this section Summary

Functions

It generates the compiled template

It generates the compiled template

It renders the compiled template using a hash with vars

Link to this section Functions

Specs

parse(String.t(), Keyword.t()) ::
  {:ok, %Solid.Template{parsed_template: term()}}
  | {:error,
     %Solid.TemplateError{
       __exception__: term(),
       line: term(),
       message: term(),
       reason: term()
     }}

It generates the compiled template

Link to this function

parse!(text, opts \\ [])

View Source

Specs

parse!(String.t(), Keyword.t()) ::
  %Solid.Template{parsed_template: term()} | no_return()

It generates the compiled template

Link to this function

render(template_or_text, values, options \\ [])

View Source

It renders the compiled template using a hash with vars

Options

  • tags: map of custom render module for custom tag. Ex: %{"my_tag" => MyRenderer}
  • file_system: a tuple of {FileSytemModule, options}. If this option is not specified, Solid use Solid.BlankFileSystem which raise error when you use render tag. You can use Solid.LocalFileSystem or implement your own file system. Please read Solid.FileSytem for more detail.

Example:

fs = Solid.LocalFileSystem.new("/path/to/template/dir/")
Solid.render(template, vars, [file_system: {Solid.LocalFileSystem, fs}])