Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "pl_mustache"

Rating:Not rated. Create the first rating!
Latest version:1.0.0
SHA1 sum:e58b9aa11b254d5012d923c2eadccc3c0f3116bd
Author:Milan Unger <nilan.unger@siemens-healthineers.com>
Home page:https://github.com/milung/pl_mustache.git


No reviews. Create the first review!.

Details by download location



Prolog implementation and predicates for {{mustache}} templating system.

Supports all features of the mustache spec, with the following specifics:

  • Lambdas: If the value associated with the property is term of the form ?(Goal) then the output is produced by the execution of the predicate once(call(Goal, Value, Result)) where result is consider as the actual value associated with the property.
  • Extensions: The proeprty values may be passed to the goals and transformed before being placed to the output list. THis may be achieved by the syntax:
    Some transformed {{?- my_goal. variable }}

    In this case the output is produced by calling once(call(my_goal, Value, Result)). The goal itself is retrieved by the call to the read_term/2 therefore it must be ended by a dot.


Use module mustache


:- use_module(library(`mustache`)).

hallo :-
    mustache_from_file('index.mustache', _{ name: 'World' }, Output },

Exported predicates

`mustache(+Variables:list, +In:codes)//` is det

Converts mustache template into the rendered text by replacing {{ variable }} placeholders with the variables specified in the Variables list. Variables is either list of terms Var - Value or Var = Value, or Variables and properties may be made of dicts. The value can be atomic, codes, string, or list of values, or if used with extension then any valid prolog term

mustache_from_file(+FileSpec, +Variables:list, -Out:codes) is det

Same as mustache//2 but loads the template from the FileSpec. FileSpec is resolved by absolute_file_name/3.


The script run-tests.ps1 executes the tests


To debug the module, load the debug.pl file into prolog top.

Contents of pack "pl_mustache"

Pack contains 8 files holding a total of 17.3K bytes.