site.fabricate.prototype.read
Namespace

Parsing + evaluation utilities for embedded Clojure forms. The functions in this namespace split the text into a sequence of Hiccup forms and embedded expressions, which is then traversed again to evaluate it, embedding (or not) the results of those expressions within the Hiccup document.

The grammar of page templates is defined in the site.fabricate.prototype.read.grammar namespace. This namespace builds on that one to walk through the parse tree of Clojure expressions produced by the template grammar and evaluate them.

An overview of the template grammar with examples is provided in the page A Reference to Fabricate's Page Templates.

Functions

read-error?
Description
Returns true if the given expression failed to read into a valid Clojure form.
Arguments
  • [error-form]
fabricate-expr?
Description
Returns true if the given value matches the schema for parsed Fabricate expressions.
Arguments
    error->hiccup
    Description
    Return a Hiccup form with context for the error.
    Arguments
    • [{:keys [expr-src exec expr error result display] :as parsed-expr}]
    parsed-form->expr-map
    Description
    Transforms the results of a parsed Fabricate expression into the map used for evaluation.
    Arguments
    • [parsed-form]
    eval-parsed-expr
    Description
    Evaluates the given expression form. Returns the value of the evaluated expression by default. Can optionally return a map with the value and also perform post-validation on the resulting value.
    Arguments
    • [{:keys [expr-src expr exec error result display fabricate.read/parse-error] :as expr-map} simplify? post-validator]
    • [expr simplify?]
    • [expr]
    eval-all
    Description
    Walks the parsed template and evaluates all the embedded expressions within it. Returns a Hiccup form.
    Arguments
    • [parsed-form simplify? nmspc]
    • [parsed-form simplify?]
    • [parsed-form]
    get-metadata
    Description
    Get the metadata form from the parse tree.
    Arguments
    • [expr-tree]
    get-file-metadata
    Description
    Get the metadata of the file used by Fabricate.
    Arguments
    • [file-path]
    extended-form->form
    Description
    Converts the parsed grammar describing an extended form to a Hiccup form.
    Arguments
    • [[tag open front-matter [_ & forms] close :as ext-form]]
    read-template
    Description
    Parses the given template and adds line and column metadata to the forms.
    Arguments
    • [template-txt]
    yank-ns
    Description
    Pulls the namespace form out of the first expression in the parse tree.
    Arguments
    • [expr-tree]
    parse
    Description
    Parses the template into a Hiccup expression with unevaluated forms.
    Arguments
    • [src {:keys [start-seq filename] :or {start-seq [] filename ""}}]
    • [src]
    form->hiccup
    Description
    If the form has no errors, return its results. Otherwise, create a hiccup form describing the error.
    Arguments
    • [{:keys [expr-src exec expr error result display] :as parsed-expr}]

    Constants

    parsed-expr-schema
    Description
    Schema describing the map used by Fabricate to evaluate forms embedded within page templates.
    Type
    :malli.core/schema
    metadata-schema
    Description
    Malli schema for unevaluated metadata form/map
    Type
    :malli.core/schema
    file-metadata-schema
    Description
    Schema describing a map of file metadata used by fabricate
    Type
    :malli.core/schema
    evaluated-expr-schema
    Description
    Schema describing a map containing the results of an evaluated Fabricate expression.
    Type
    :malli.core/schema
    error-form-schema
    Description
    Malli schema describing Hiccup forms that contain error messages
    Type
    :malli.core/schema
    parsed-schema
    Description
    Malli schema describing the elements of a fabricate template after it has been parsed by the Instaparse grammar.
    Type
    :malli.core/schema