Text templates

Author(s): Jose F. Morales, The 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

Documentation on exports

Usage:eval_template_file(InFile,Subst,OutFile)

Like eval_template_string/3, using files.

    Usage:eval_template_string(In,Subst,Out)

    Evaluate the template string In to generate Out using the values in Subst.

      Documentation on imports

      This module has the following direct dependencies:

      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.