Text Templates
Author(s): Jose F. Morales, Ciao Development Team.A template is a text marked-up with special tags that contain expressions. Template evaluation replaces tags with the evaluation of such expressions, w.r.t. a substitution of parameters.
Tags must have the form {{Expr}}, where Expr is a parameter name.
Example: given the file n.txt.skel:
Dear {{Author}}, on behalf of the program committee of {{Conf}}, we are pleased to inform you that your paper {{Title}} has been accepted for inclusion in the post-conference proceedings.
then the query:
?- eval_template_file('n.txt.skel', [ 'Author' = 'Alain', 'Title' = 'The Birth of Prolog', 'Conf' = 'CACM 93' ], 'n.txt').
produces the following text:
Dear Alain, on behalf of the program committee of CACM 93, we are pleased to inform you that your paper The Birth of Prolog has been accepted for inclusion in the post-conference proceedings.
Usage and interface
- Library usage:
:- use_module(library(text_template)). - Exports:
- Predicates:
eval_template_file/3, eval_template_string/3.
- Predicates:
- Imports:
- System library modules:
regexp_code, lists, file_utils, dict. - Packages:
prelude, nonpure, condcomp, assertions, regtypes, isomodes, hiord, regexp.
- System library modules:
Documentation on exports
PREDICATE
PREDICATE
Usage:eval_template_string(In,Subst,Out)
Evaluate the template string In to generate Out using the values in Subst.
Known bugs and planned improvements
- Extend tag expression language. Probably we could turn inside-out a DCG goal to get both good performance and features.
- The implementation can be improved.