Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-04

Mustache templates implementation

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello ,

For my job I needed a Mustache templates library in pascal.

Since dmustache (part of mORMot) fails the official mustache tests and did not work on the platform I needed it for, I wrote my own implementation.

The result has been committed to packages/fcl-mustache, in case someone else has a need for it.

Basic Features:
- TMustache Component, can be dropped on a form.
- Compiles the template, so repeated output should be fast.
- Passes all official testcases (including weird whitespace rules).
- JSON data input by default.
- Output easily configurable.

Extra:
- Integration with FPExprPars engine for expressions: {{[age + 2]}} will work.
- You can use datasets as source of data.
- Written to be easily extendable with other features.
- Unit tested.

Demos available, there is a complete usable command-line program that has all features enabled.

Enjoy,

Michael.

Reply by email

leledumbo
to Michael Van Canneyt
Since dmustache (part of mORMot) fails the official mustache tests and did

not work

on the platform I needed it for, I wrote my own implementation.

I do remember it didn't pass all the tests, but still works for my needs so I let it be.

The result has been committed to packages/fcl-mustache, in case someone else has a need for it.

Now thank you for this, I'll be sure to check it out to replace dmustache.

Reply by email

Michael Van Canneyt
to leledumbo
leledumbo wrote 6 lines
> Since dmustache (part of mORMot) fails the official mustache tests and did not work > on the platform I needed it for, I wrote my own implementation. I do remember it didn't pass all the tests, but still works for my needs so I let it be.

My biggest beef is that it does not work on all platforms, because it pulls in some of mORMot. My implementation just needs the classes and sysutils units..

Show quoted text 6 lines
> The result has been committed to packages/fcl-mustache, in case someone > else > has a need for it. Now thank you for this, I'll be sure to check it out to replace dmustache.

I'm currently porting it to Delphi (where I'll eventually need it) and will publish those sources too on gitlab or so.
Delphi's JSON handling is not compatible to FPC's so some minor changes are needed.

Michael.

Reply by email

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 11 lines
> >> The result has been committed to packages/fcl-mustache, in case someone >> else >> has a need for it. > > Now thank you for this, I'll be sure to check it out to replace dmustache. I'm currently porting it to Delphi (where I'll eventually need it) and will publish those sources too on gitlab or so. Delphi's JSON handling is not compatible to FPC's so some minor changes are needed.

For those interested, I published the Delphi code at: https://gitlab.com/mvancanneyt/mustached

Michael.

Reply by email