~bakpakin/temple

ref: ed7e83e8779e2a54e23bbbcc75366ade2dd5372a temple/README.md -rw-r--r-- 956 bytes
ed7e83e8Calvin Rose . 1 year, 3 months ago

#Temple

HTML templates for Janet.

Simplified version of Mendoza's template system that is cleaner and easier to use. Templates can be used recursively, and output is printed via print, so goes to (dyn :out).

Expands on the mendoza templates with the {- ... -} brackets, which do non-escaped substitution, so temple can be used for formats besides HTML. Also exposes the escape function inside templates for HTML escaping if you want to manually print to template output.

#Example

#foo.temple

{$ (def n 20) # Run at template compile time $}
<html>
  <body>
    {{ (string/repeat "<>" n) # HTML escaped }}
    <ul>
      {% (each x (range n) (print "<li>" x " " (args :a) "</li>")) # No auto-print %}
    </ul>
    {- (string/repeat "<span>1</span>" n) # Not HTML escaped -}
  </body>
</html>

#main.janet

(import temple)
(temple/add-loader)

(import ./foo :as foo)
(foo/render :a "hello")