mustache4c
mustache4c copied to clipboard
C {{mustache}} parser library.
Mustache4C Readme
- Home: https://github.com/mity/mustache4c
What is {{mustache}}
{{mustache}} is logic-less template system. The term "logic-less" means
it lacks any explicit if or else conditionals or for loops, however both
looping and conditional evaluation can be achieved using section tags
processing lists.
It is named {{mustache}} because of heavy use of curly braces ({ and })
which resemble a sideways mustache.
{{mustache(5)}} can provide you an idea about {{mustache}} capabilities and its syntax. More advanced use and understanding can be reached if you immerse in {{mustache}} official specification.
What is Mustache4C
Mustache4C is C implementation of {{mustache}} parser and processor, intended mainly for embedding in other C/C++ code.
Note it does not enforce any explicit data structures for data. Many other implementations assume some particular data storage (typically JSON) which is ready and provided before the template processing begins.
Instead of that, Mustache4C asks the application for any data referred
from the template via some callback functions, and Mustache4C does not
assume anything but tree hierarchy of those data and that each node in the
tree may be represented with a single opaque pointer (void*).
This even allows the application to generate the data on the fly, or retrieve it from a database instead of getting and preparing whole data set beforehand in the computer memory.
A documentation of its API is currently only available directly in the header
file mustache.h.
Current Status
Specification Conformance
Mustache4C is compliant to {{mustache}} specification 1.3.0.
-
[x] Variables (
{{foo}},{{{bar}}}): Implemented. All spec tests are passing. -
[x] (Regular) Sections (
{{#foo}} ... {{/foo}}): Implemented. All spec tests are passing. -
[x] Inverted Sections (
{{^foo}} ... {{/foo}}): Implemented. All spec tests are passing. -
[x] Comments (
{{! foo bar }}): Implemented. All spec tests are passing. -
[x] Partials (
{{>foo}}): Implemented. All spec tests are passing. -
[x] Set Delimiter (
{{=<% %>=}}): Implemented. All spec tests are passing.
Extensions
Currently none.
Note about Lambdas
The design of Mustache4C in general supports generating or retrieving some data in run-time, which more or less allows application to support lambda. But such implementation is and will be on the application using Mustache4C, and the implementation likely shall be limited to things needed by the application.
Full lambda support as seen in many modern scripting languages is not and will not be supported by Mustache4C.
License
Mustache4C is covered with MIT license, see the file LICENSE.md.
Reporting Bugs
If you encounter any bug, please be so kind and report it. Unheard bugs cannot get fixed. You can submit bug reports here:
- https://github.com/mity/mustache4c/issues