MxBlog

Mustache templating for Mendix

I've uploaded a mustache templating module for Mendix to Github. It enables you to use mustache templating from a microflow. I use it to generate pdf documents (embed the resulting html in a document generator template), but you can also generate xml, json or csv if you like.

The readme has a couple of examples. The module supports associations, so you can generate a list of object:

| Brand | Model | HasTurbo | CarId | Price | Doors | Color | DateIntroduction |
|:----- |:----- |:-------- | -----:| -----:| -----:|:----- |:---------------- |
{{#Car_CarList}}
| {{Brand}} | {{Model}} | {{HasTurbo}} | {{CarId}} | {{Price | money}} | {{Doors}} | {{Color}} |         {{DateIntroduction | dd-MM-yyyy}} |
{{/Car_CarList}}

The module can also convert markdown to html as used by this example.

I've added some formatting extensions, so you can specify the format you want to use when printing dates for example. This is used in the following example that generate json:

[
{{#Car_CarList}}
{ "Brand" : "{{Brand}}",
  "Model" : "{{Model}}",
  "HasTurbo" : {{HasTurbo}},
  "CarId" : {{CarId}},
  "Price" : {{Price}},
  "Doors" : {{Doors}},
  "Color" : "{{Color}}",
  "DateIntroduction" : "{{DateIntroduction | yyyy-MM-dd''T''HH:mm:ss.SSSZ}}"
},
{{/Car_CarList}}
]

Please take care, this is a first release, probably full of bugs.