Positron::DataTemplate is a templating engine. Unlike most templating engines, though, it does not work on text, but on raw data: the template is (typically) a hash or array reference, and the result is one, too.

This module rose from a script that regularly produced HTML snippets on disk, using regular, text-based templates. Each use case used the same data, but a different template. For one use case, however, the output was needed in JSON format, not HTML. One solution would have been to use the text-based templating system to produce a valid JSON document (quite risky). The other solution, which was taken at that time, was to transform the input data into the desired output structure in code, and use a JSON serializer on that, bypassing the template output.

The third solution would have been to provide a template that did not directly produce the serialised JSON text, but described the data structure transformation in an on-disc format. By working only with structured data, and never with text, the serialized output must always be valid JSON.

This (minus the serialization) is the domain of Positron::DataTemplate.

This code is still being worked on. This includes the documentation. In the meanwhile, please use the following examples (and some trial & error) to gain a first look. Alternatively, if you have access to the tests of this distribution, these also give some examples.