Transformer, generates text files using the {{ mustache }} template.

Entity class IRI
IRI of the RDF class of the objects, to which the {{ mustache }} template is applied.
Mustache template
The {{ mustache }} template


RDF data
Look in pipeline
Sample pipeline

First, we recommend the potential user of this component to get to know the library itself and its demo. There, a template and a sample JSON file with data are shown and the resulting text can be generated. In LinkedPipes ETL, we work with RDF, therefore, the template placeholders will be IRIs and the data will be stored as RDF.

Mustache input data in JSON and in RDF

Below, you can see the original Mustache input data from the demo in JSON and the same input data in RDF. This can be used for comparison, because the structure and meaning remains the same.

Input data in JSON

  "header": "Colors",
  "items": [
      {"name": "red", "first": true, "url": "#Red"},
      {"name": "green", "link": true, "url": "#Green"},
      {"name": "blue", "link": true, "url": "#Blue"}
  "empty": false

Input data in RDF (Turtle)

<http://localhost/resources/1> a <http://localhost/outputClass> ;
  <http://localhost/ontology/header> "Colors" ;
  <http://localhost/ontology/item> <http://localhost/resources/1/1> ;
  <http://localhost/ontology/item> <http://localhost/resources/1/2> ;
  <http://localhost/ontology/item> <http://localhost/resources/1/3> ;
  <http://localhost/ontology/isEmpty> false ;
  <> "file.html" .

  <http://localhost/ontology/name> "blue" ; 
  <http://localhost/ontology/link> true ;
  <http://localhost/ontology/url> "#Blue" ;
  <> 2 .

  <http://localhost/ontology/name> "red" ; 
  <http://localhost/ontology/first> true ;
  <http://localhost/ontology/url> "#Red" ;
  <> 1 .

  <http://localhost/ontology/name> "green" ; 
  <http://localhost/ontology/link> true ;
  <http://localhost/ontology/url> "#Green" ;
  <> 3 .

Mustache templates for JSON and for RDF

Below, you can see the original {{ mustache }} template from the demo for the JSON data and the same template usable for RDF data in LP-ETL. This can be used for comparison, because the structure and meaning remains the same.

Template for demo JSON


    <li><a href="{{url}}">{{name}}</a></li>

  <p>The list is empty.</p>

Template for LP-ETL


    <li><a href=\"{{http://localhost/ontology/url}}\">{{http://localhost/ontology/name}}</a></li>

  <p>The list is empty.</p>

Output in HTML

The templates, when executed on the input data, both JSON data and JSON template and RDF data and LP-ETL template, produce the same result, which in this case is the following simple HTML. A sample importable {{ mustache }} pipeline fragment is available.

<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>

LP-ETL template specifics

The component looks in the input data for the instances of the entity class specified in the configuration and executes the template on each one. In our example, the entity class was http://localhost/outputClass. Note that only values stored in literals can be used by the template as IRIs are used to connect one object to another. In the case that you need to output the IRI itself, you can generate a literal version of it using, e.g. the SPARQL update before passing the data to the {{ mustache }} component. In addition to the standard {{ mustache }} usage, in LP-ETL templates there are special properties, using which you can further customize the outputs.

Output filename

The output filename property, denoted by the IRI, which can be attached to the entity class instance, can be used to generate a different file for each entity class instance.

List item order

One of the key {{ mustache }} concepts is a list of items. In JSON, the order of the items is given implicitly, because JSON is a tree and therefore each node has an ordered sequence of children. In RDF, the order of the list items needs to be specified explicitly, because the RDF data model is a generic graph. We could have used the RDF list, however, it seemed that the explicit order will be more usable. The property is denoted by the IRI and can be attached to a list item.

Prefixes in templates

  PREFIX on: <http://localhost/ontology/>
IRI: {{on:iri}}

      <a href={{@id}}>{{@id}}</a>
    <li><a href="{{on:url}}">{{on:name}}</a></li>

In order to declare namespace prefixes, you can start your Mustache template with a comment (i.e. {{! comment }}) that contains namespace declarations in the SPARQL syntax.

Generating lists

When you are generating lists, for example in JSON, you may want to use the "Add the mustache:first predicate to first items of input lists" option, which adds the predicate to the first item of each input list. You can then skip adding the list separator for that item like so: