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


fabricate-expr?
Description
Arguments
    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]
    render-src
    Description
    Escapes special characters in the source code form. Optionally removes a do block around the form.
    Arguments
    • [src-expr rm-do?]
    • [src-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]
    ->dir-local-path
    Description
    Convert the given path to a path relative to the current working directory (project root by default).
    Arguments
    • [file]
    include-source
    Description
    Includes the source code in the given file as a [:pre] Hiccup element.
    Arguments
    • [{:keys [details], :or {details nil}, :as opts} file-path]
    • [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]]
    include-form
    Description
    Return the form in the file matching the predicate as a rewrite-clj node.
    Arguments
    • [src-file pred]
    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