Z.Documents.HtmlDocuments (Portico/Z v0.1.0)
Context module for ZSchemas.Documents.HtmlDocument
Link to this section Summary
Functions
Create a ZSchemas.Documents.HtmlDocument from a ZSchemas.Documents.HtmlTemplate.
Retrieve a single ZSchemas.Documents.HtmlDocument by id
Link to this section Functions
Link to this function
create_html_document(template, opts \\ [])
Specs
create_html_document(template :: map(), opts :: list()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
Create a ZSchemas.Documents.HtmlDocument from a ZSchemas.Documents.HtmlTemplate.
You must pass an associated template. The html field of the document will be automatically calculated, using any merged variables you might pass to override defaults.
You can specify the following opts:
attrs- These will be taken as top priority and will override any other values that are automatically set. You could, for example, set[attrs: %{width_in: "12"}]to manually force a specific document width, regardless of template settings.merged_variables- A map of field/value pairs to be merged into the document. SeeZ.Documents.merge_variables/2for rules.
Examples
iex> create_html_document(some_template, merged_variables: %{age: "42"})
{:ok, %ZSchemas.Documents.HtmlDocument{}}
iex> create_html_document(some_template, attrs: %{width_in: "12"}, merged_variables: %{age: "77"})
{:ok, %ZSchemas.Documents.HtmlDocument{}}
Link to this function
get_html_document(id)
Specs
Retrieve a single ZSchemas.Documents.HtmlDocument by id
Examples
iex> Z.Documents.HtmlTemplates.get_html_document("abc-123-def-456")
%ZSchemas.Documents.HtmlDocument{}
iex> Z.Documents.HtmlTemplates.get_html_document("doesntexist")
nil