The cl-template Reference Manual

This is the cl-template Reference Manual, version 0.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Jan 15 05:29:48 2023 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-template

A simple output-agnostic templating system for Common Lisp.

Author

Peter Cannici <>

License

MIT

Version

0.0.1

Source

cl-template.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 cl-template/cl-template.asd

Source

cl-template.asd.

Parent Component

cl-template (system).

ASDF Systems

cl-template.


3.1.2 cl-template/packages.lisp

Source

cl-template.asd.

Parent Component

cl-template (system).

Packages

3.1.3 cl-template/util.lisp

Dependency

packages.lisp (file).

Source

cl-template.asd.

Parent Component

cl-template (system).

Internals

3.1.4 cl-template/cl-template.lisp

Dependencies
Source

cl-template.asd.

Parent Component

cl-template (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 cl-template

Source

packages.lisp.

Nickname

clt

Use List

common-lisp.

Public Interface
Internals

4.2 cl-template-template-symbols

Source

packages.lisp.

Use List

common-lisp.


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *add-progn-to-if*

Boolean; whether or not to implicitly add a progn to IF expressions.

Package

cl-template.

Source

cl-template.lisp.


5.1.2 Ordinary functions

Function: compile-template (string &key start-delimiter start-echo-delimiter end-delimiter)

Compile a string template into a lambda, which can be invoked with
a plist as the only argument and provides data to the template. The
data argument to the lambda is available in the template as
‘cl-template::__data‘, although it’s not recommended to use it
directly. See README.md for examples of the template syntax.
It caches the result of the compilation.
Examples:
(compile-template "the number is <%= (@ number) %>") ; (lambda (__data) ...)
(compile-template "{{= @ mood }} shark" :start-delimiter "{{" :start-echo-delimiter "{{=" :end-delimiter "}}") ; (lambda (__data) ...) (funcall (compile-template "<%= format nil "~@r" (@ number) %>") ’(:number 12)) ; "XII"

Package

cl-template.

Source

cl-template.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *template-fn-cache*

Hash table which compiled template functions are cached in.

Package

cl-template.

Source

cl-template.lisp.


5.2.2 Ordinary functions

Function: add-progn-to-if-expression (expression)
Package

cl-template.

Source

cl-template.lisp.

Function: compile-echo-expression (code stream expressions stack)
Package

cl-template.

Source

cl-template.lisp.

Function: compile-expression (code stream expressions stack)
Package

cl-template.

Source

cl-template.lisp.

Function: compile-string (string stream expressions stack)
Package

cl-template.

Source

cl-template.lisp.

Function: compile-template-part (string start start-delimiter start-echo-delimiter end-delimiter stream expressions stack)
Package

cl-template.

Source

cl-template.lisp.

Function: handle-end-expression (expressions stack)
Package

cl-template.

Source

cl-template.lisp.

Function: internal-compile-template (string start-delimiter start-echo-delimiter end-delimiter stream-name)
Package

cl-template.

Source

cl-template.lisp.

Function: match-pairs-ignoring (string pair &key ignore-list start end)

Count the occurences of a pair (e.g. []) in a string, ignoring any that occur in between pairs of ‘ignore-list‘. Example:
(match-pairs-ignoring "(something)" ’(#( . #))) ; t
(match-pairs-ignoring "[that <thing]>" ’(#[ . #]) :ignore-list ’((#< . #>))) ; nil

Package

cl-template.

Source

util.lisp.

Function: scan-between-delimiters (string start-delimiter end-delimiter &key ignore-list start end)

Scan a string and return a substring between the two delimiter substrings.
Example:
(scan-between-delimiters "abc <%= thingy %> def" "<%=" "%>") ; " thingy "
(scan-between-delimiters "what{{ever stuff<ignor{{ing>{{now}}xyz" :ignore-list ’((#< . #>)) :start 10) ; "now"

Package

cl-template.

Source

util.lisp.

Function: scan-string-until-ignoring (string terminator &key ignore-list start end)

Scan a string until a substring is encountered, ignoring anything
between ignore-list pairs. Probably not super-useful outside of
CLT. In CLT it is used to scan until the next end delimiter while
ignoring things in quotes.
Example:
(scan-string-until-ignoring "abc|def" "|") ; "abc"
(scan-string-until-ignoring "abc <ignor|ing> def" "|" :ignore-list ’((#< . #>))) ; "abc <ignor|ing> def"

Package

cl-template.

Source

util.lisp.


Appendix A Indexes


A.1 Concepts