Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 3.03 KB

README.md

File metadata and controls

50 lines (36 loc) · 3.03 KB

Dali Template Engine

GitHub release Travis Status Coverage Status raco pkg install dali Documentation GitHub stars MIT License

Dali is a Racket implementation of a language similar to Mustache and Handlebars. It tries to be as faithful as possible to Mustache, providing a simple and high-level idiomatic module for callers. Not all features of Handlebars are implemented, or implemented in the same manner, as they are more JavaScript focused.

Modules

  • dali - template engine module, provides compile-string, expand-string, and expand-file functions for template expansion. The expand functions rely on the compile function to read the template and convert it into a Racket function for performance and re-use.

Example

The following example expands a very simple template with a nested list. Note that the context provided to the expansion function is simply comprised of hash? and list? structures.

(require dali)
(define template "a list: {{#items}} {{item}}, {{/items}}and that's all")
(define context (hash "items" (list (hash "item" "one")
                                    (hash "item" "two")
                                    (hash "item" "three"))))
(expand-string template context)

The module also provides a cache for loaded and compiled partial to support greater performance.

Installation

  • To install (from within the package directory): raco pkg install
  • To install (once uploaded to pkgs.racket-lang.org): raco pkg install dali
  • To uninstall: raco pkg remove dali
  • To view documentation: raco docs dali

History

  • 1.1 - Feature Stable Release

    • Completed documentation, using Mustache flow and examples.
    • Refactored the compiled code for sections, it's now much faster and cleaner.
    • Updated escaping to match the Mustache spec.
    • Support more simple value options, numbers, symbols, booleans, and characters.
    • Added error-missing-value-handler.
  • 1.0 - Initial Version

Racket Language