Summary
As announced previously, I recently wrote an implementation of JSON Template in Typed Racket. This is a port of the original untyped Racket code to R6RS.
Like the Racket version, it is likely to contain a number of bugs because of lack of real-world usage.
JSON Template is a minimalistic, declarative template language.
Downloading
You can fetch the Mercurial repository using the following command:
hg clone http://matthias.benkard.de/code/json-template-r6rs/
(Mind the trailing slash. My web server is overly picky there.)
Documentation and Installation
See the manual for installation and usage instructions.
Dependencies
JSON Template for R6RS depends on the pregexp library.
Implementation Features
- HTML and URI escaping through the use of formatters
- Supports both association lists and hash tables as input data
- Configurable meta characters
- GPLv3 license
Missing Things
- Literals (like
{.space}
and{.meta-left}
/
{.meta-right}) - Multiple-argument formatters
- Some kind of compilation for efficiency
Examples
Example code:(define template-string " <h1>{title|html}</h1> {.section people} <ul> {.repeated section @} <li>{name} ({age} years)</li> {.end} </ul> {.or} <p>No one's registered.</p> {.end}") (define template (make-template template-string)) (template '((title . "<Registered People>") (people . (((name . "Nathalie") (age . 24)) ((name . "Heinrich") (age . 28)) ((name . "Hans") (age . 25)))))))
Result:
<h1><Registered People></h1> <ul> <li>Nathalie (24 years)</li> <li>Heinrich (28 years)</li> <li>Hans (25 years)</li> </ul>
Comments
Submit a comment
Note: This website uses a JavaScript-based spam prevention system. Please enable JavaScript in your browser to post comments. Comment format is plain text. Use blank lines to separate paragraphs.