(html (head (title "sph-lib (sph lang template)") (link (@ (rel "stylesheet") (type "text/css") (href "/css/sph.css"))) (meta (@ (name "viewport") (content "width=device-width,initial-scale=1"))) #f) (body () (div (@ (class top)) (nav (a (@ (href "/")) "start") ", " (a (@ (href "/feed.xml")) "feed")) "") (div (@ (class "middle")) (div (@ (class mtime) (title "last modification time of the current page")) "2018-10-22") (section (h1 "(sph lang template)") (div (p "s-expression template processor.") (p "part of " (a (@ (href "../../sph-lib.html")) "sph-lib")) ((section (@ (class "library-description")) (h1 "library description") (div (p "a template engine that interprets expressions as elements of a quasiquoted list.") (p "supports concatenation and composition. source data can be given as files, ports or datums.") (p "creates template procedures.") (p "alternative name: s-template") (p "# data structures") (p "template-procedure :: procedure:{symbol:key [default] -> variable-value} any:content -> any") (p "template-source: element/(element/(element ...) ...)") (p "template-source: single-elements/(concatenated-elements/(composed-elements ...) ...)") (p "element: string:path/procedure:template-procedure/port/any"))) (section (@ (class "library-name")) (h1 "import name") (p "(sph lang template)")) (section (@ (class "library-exports")) (h1 "exports") (div (ul (@ (class "doc-index")) (li (a (@ (href "#doc-b-" "sph-lang-template-description") (class (variable))) "sph-lang-template-description")) (li (a (@ (href "#doc-b-" "template-bindings-proc") (class (procedure))) "template-bindings-proc")) (li (a (@ (href "#doc-b-" "template-compose") (class (procedure))) "template-compose")) (li (a (@ (href "#doc-b-" "template-datum->template-proc") (class (procedure))) "template-datum->template-proc")) (li (a (@ (href "#doc-b-" "template-fold") (class (procedure))) "template-fold")) (li (a (@ (href "#doc-b-" "template-get") (class (procedure))) "template-get"))) (div (@ (class "doc-bindings")) (div (@ (id "doc-b-" "sph-lang-template-description") (class "doc-b")) (div (span (@ (class "type")) "variable") ": " (span (@ (class "name")) "sph-lang-template-description")) "" "") (div (@ (id "doc-b-" "template-bindings-proc") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "template-bindings-proc") " " (span (@ (class "first-sig")) "data ->")) "" "") (div (@ (id "doc-b-" "template-compose") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "template-compose") " " (span (@ (class "first-sig")) "env source ... ->")) (div (@ (class "rest-sig")) (div "environment template-source ... -> procedure:template-proc")) (div (@ (class "description")) ("evaluated templates from source are passed as content to the templates before them like function composition"))) (div (@ (id "doc-b-" "template-datum->template-proc") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "template-datum->template-proc") " " (span (@ (class "first-sig")) "a env ->")) (div (@ (class "rest-sig")) (div "any:scheme-datum environment -> procedure:template-proc")) (div (@ (class "description")) ("creates a template-procedure from an unevaluated template scheme datum.\nadditionally to the bindings from the given environment, the bindings \"v\" and \"content\" are available in scope.\nv can be used as (v (quote variable-name)) to insert template variables. content contains the value\neventually inserted via composition"))) (div (@ (id "doc-b-" "template-fold") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "template-fold") " " (span (@ (class "first-sig")) "fold-proc bindings env source custom-values ... ->")) (div (@ (class "rest-sig")) (div "procedure:{procedure any -> any} list environment template-source any -> any")) (div (@ (class "description")) ("template-fold processes multiple template sources. it creates the s-expression structure\nwith variables replaced and passes individual expressions to fold-proc which can then process them further,\nfor example translate sxml to an xml string.\nhow sources are combined depends on the nesting depth they are specified with.\nfirst nesting level: (a b c ...)\n templates are appended\nsecond nesting level: (a (b c d) ...)\n templates are composed/inserted. similar to function application, template b receives the result of template c,\n which receives the result of template d. this is appended to a\nsource elements can be filesystem path strings, template procedures or other scheme datums.\nif the datums to insert are lists, then they should be nested in two lists (((content ...))) to avoid the automatic\nconcatenation or composition.\nexample call\n (template-fold\n (l (template-result . custom-values) (pair template-result custom-values))\n (list \"file.sxml\" \"appended-file.sxml\" (list \"layout.sxml\" \"inserted-into-layout.sxml\"))\n (alist-q a 1)\n (environment (rnrs base))\n (list))"))) (div (@ (id "doc-b-" "template-get") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "template-get") " " (span (@ (class "first-sig")) "env a ->")) (div (@ (class "rest-sig")) (div "environment procedure/string/port/any -> procedure")) "")))))))) ()))