site.fabricate.prototype.read.grammar Namespace

Instaparse grammar for Fabricate's page templates.


The grammar definition

This Instaparse grammar defines the structure of Fabricate templates. Once parsed into an Instaparse parse tree, the read namespace walks the parsed template and evaluates the expressions embedded within it. The grammar, as defined, intentionally does not concern itself with whether the contents of the expressions in each template are syntactically valid Clojure forms; that task is left to the reader. Defining the grammar this way allows Clojure read errors to be caught and handled on a form-by-form basis instead of throwing an error for the whole page.

template = Īµ | (expr | txt | extended-form)*
terminal = "šŸ”š" var-settings?
form-contents = (expr | txt | extended-form)+
var-settings = #"[\uFE00-\uFE0F]"
txt = #"(\A[^āœ³šŸ”š]*+\Z)|([\S\s]*?(?=\Z|(?:[\]})]//šŸ”š|āœ³|šŸ”š)))"
ctrl = "=" | "+" | "+="
extended-form =  <"//"> "[" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents "]" <"//">  |  <"//"> "(" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents ")" <"//">  |  <"//"> "{" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents "}" <"//"> 
expr =  !"//" ctrl? #"[^=+][^šŸ”š]*" !"//" 
initial = "āœ³" var-settings?

For an informal guide to how these templates get used with examples, please see the page A Reference to Fabricate's Page Templates.

Constants


Error
Error type
class clojure.lang.Compiler$CompilerException
Error message
No such var: page/expr->hiccup
Error phase
:compile-syntax-check
Location
Lines 27-34, Columns 1-28
Source expression
 [:div (->> vars
         (filter (fn [[k v]] (not (fn? (var-get v)))))
         (reduce (fn [l [k v]]
(conj l [:dt [:code {:class "language-clojure symbol"} k]]
      [:dd [:dl [:dt "Description"] [:dd (:doc (meta v))]
            [:dt "Type"]
            [:dd [:code (page/expr->hiccup (type (var-get v)))]]]]))
                 [:dl]))]