Discussion:
[fpc-pascal] Mustache templates implementation
Michael Van Canneyt via fpc-pascal
2021-04-20 12:20:34 UTC
Permalink
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.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/m
leledumbo via fpc-pascal
2021-04-20 22:46:08 UTC
Permalink
Post by Michael Van Canneyt via fpc-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.
I do remember it didn't pass all the tests, but still works for my needs so
I let it be.
Post by Michael Van Canneyt via fpc-pascal
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.



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bi
Michael Van Canneyt via fpc-pascal
2021-04-21 06:13:04 UTC
Permalink
Post by Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Since dmustache (part of mORMot) fails the official mustache tests and did
not work
Post by Michael Van Canneyt via fpc-pascal
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..
Post by Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
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.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fp
Michael Van Canneyt via fpc-pascal
2021-04-23 11:14:36 UTC
Permalink
Post by Michael Van Canneyt via fpc-pascal
Post by leledumbo via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
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.


_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc

Loading...