{"id":22568095,"url":"https://github.com/rekgrpth/mustach","last_synced_at":"2025-10-08T16:04:23.183Z","repository":{"id":104666537,"uuid":"331243498","full_name":"RekGRpth/mustach","owner":"RekGRpth","description":"C implementation of mustache templating","archived":false,"fork":false,"pushed_at":"2025-10-02T19:07:09.000Z","size":563,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T16:02:47.667Z","etag":null,"topics":["c","mustache"],"latest_commit_sha":null,"homepage":"https://gitlab.com/jobol/mustach ","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RekGRpth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-20T08:40:03.000Z","updated_at":"2025-10-02T19:07:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdb69b9e-ca15-4c33-b010-8e40ce2406cf","html_url":"https://github.com/RekGRpth/mustach","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/RekGRpth/mustach","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fmustach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fmustach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fmustach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fmustach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RekGRpth","download_url":"https://codeload.github.com/RekGRpth/mustach/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RekGRpth%2Fmustach/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278972327,"owners_count":26078019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","mustache"],"created_at":"2024-12-08T00:11:19.938Z","updated_at":"2025-10-08T16:04:23.137Z","avatar_url":"https://github.com/RekGRpth.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction to this preview of Mustach 2\n\nCAUTION! ===================================================================\n\nCAUTION! THIS DOCUMENT IS A WORK IN PROGRESS README FOR THE COMING VERSION 2\n\nCAUTION! ===================================================================\n\n\n`mustach` is a C implementation of \n[mustache](http://mustache.github.io \"main site for mustache\")\ntemplate specification, version 1.4.1, only the mandatory part.\n\nThe main site for `mustach` is [gitlab](https://gitlab.com/jobol/mustach).\n\nThis version of mustach, the version 2, introduce many changes\nwhen compared to previous versions but is still upward compatible.\nSo people used to previous versions should not be afraid by the changes\nbecause their code will continue to work as before.\n\nThe version 2 comes with 3 flavours of the rendering algorithm:\nthe minimal, the optimal and the legacy.\n\nThe minimal rendering algorithm is a cleaned up rewrite of the previous\nversions. It does not make any memory allocation, it has a simple\ninterface, it is well suited for little embedded systems.\nBut it is not efficient for high volumes or stressfull usage of\nmustache templating. And at the moment it does not implement inheritance\n(parent and bloc).\n\nThe simplest way to use minimal mustach implementation is to copy the files\n**mini-mustach.h** and **mini-mustach.c** directly into your project and to use it.\n\n...\n\nIf you are using one of the JSON libraries listed below, you can get extended feature\nby also including **mustach-wrap.h**, **mustach-wrap.c**, **mustach-XXX.h** and\n**mustach-XXX.c** in your project (see below for **XXX**)\n\n- [json-c](https://github.com/json-c/json-c): use **XXX** = **json-c**\n- [jansson](http://www.digip.org/jansson/): use **XXX** = **jansson**\n- [cJSON](https://github.com/DaveGamble/cJSON): use **XXX** = **cjson**\n\nAlternatively, make and meson files are provided for building `mustach` and\n`libmustach.so` shared library.\n\nSince version 1.0, the makefile allows to compile and install different\nflavours. See below for details.\n\n## Distributions offering mustach package\n\n### Alpine Linux\n\n```sh\napk add mustach\napk add mustach-lib\napk add mustach-dev\n```\n\n### NetBSD\n\n```sh\ncd devel/mustach\nmake\n```\n\nSee http://pkgsrc.se/devel/mustach\n\n## Known projects using Mustach\n\nThis [wiki page](https://gitlab.com/jobol/mustach/-/wikis/projects-using-mustach)\nlists the known project that are using mustach and that kindly told it.\n\nDon't hesitate to tell us if you are interested to be listed there.\n\n## Using Mustach from sources\n\nThe file **mustach.h** is the main documentation. Look at it.\n\nThe current source files are:\n\n- **mustach.c** core implementation of mustache in C\n- **mustach.h** header file for core definitions\n- **mustach-wrap.c** generic wrapper of mustach for easier integration\n- **mustach-wrap.h** header file for using mustach-wrap\n- **mustach-json-c.c** tiny json wrapper of mustach using [json-c](https://github.com/json-c/json-c)\n- **mustach-json-c.h** header file for using the tiny json-c wrapper\n- **mustach-cjson.c** tiny json wrapper of mustach using [cJSON](https://github.com/DaveGamble/cJSON)\n- **mustach-cjson.h** header file for using the tiny cJSON wrapper\n- **mustach-jansson.c** tiny json wrapper of mustach using [jansson](https://www.digip.org/jansson/)\n- **mustach-jansson.h** header file for using the tiny jansson wrapper\n- **mustach-tool.c** simple tool for applying template files to one JSON file\n\nThe file **mustach-json-c.c** is the historical example of use of **mustach** and\n**mustach-wrap** core and it is also a practical implementation that can be used.\nIt uses the library json-c. (NOTE for Mac OS: available through homebrew).\n\nSince version 1.0, the project also provide integration of other JSON libraries:\n**cJSON** and **jansson**.\n\n*If you integrate a new library with* **mustach**, *your contribution will be\nwelcome here*.\n\nThe tool **mustach** is build using `make`,  its usage is:\n\n    mustach json template [template]...\n\nIt then outputs the result of applying the templates files to the JSON file.\n\n### Portability\n\nSome system does not provide *open_memstream*. In that case, tell your\npreferred compiler to declare the preprocessor symbol **NO_OPEN_MEMSTREAM**.\nExample:\n\n\tCFLAGS=-DNO_OPEN_MEMSTREAM make\n\n### Integration\n\nThe files **mustach.h** and **mustach-wrap.h** are the main documentation. Look at it.\n\nThe file **mustach-json-c.c** provides a good example of integration.\n\nIf you intend to use basic HTML/XML escaping and standard C FILE, the callbacks\nof the interface **mustach_itf** that you have to implement are:\n`enter`, `next`, `leave`, `get`.\n\nIf you intend to use specific escaping and/or specific output, the callbacks\nof the interface **mustach_itf** that you have to implement are:\n`enter`, `next`, `leave`, `get` and `emit`.\n\n### Compilation Using Make\n\nBuilding and installing can be done using make.\n\nExample:\n\n    $ make tool=cjson libs=none PREFIX=/usr/local DESTDIR=/ install\n    $ make tool=jsonc libs=single PREFIX=/ DESTDIR=$HOME/.local install\n\nThe makefile knows following switches (\\*: default):\n\n     Switch name  | Values  | Description\n    --------------+---------+-----------------------------------------------\n     jsonc        | (unset) | Auto detection of json-c\n                  | no      | Don't compile for json-c\n                  | yes     | Compile for json-c that must exist\n    --------------+---------+-----------------------------------------------\n     cjson        | (unset) | Auto detection of cJSON\n                  | no      | Don't compile for cJSON\n                  | yes     | Compile for cJSON that must exist\n    --------------+---------+-----------------------------------------------\n     jansson      | (unset) | Auto detection of jansson\n                  | no      | Don't compile for jansson\n                  | yes     | Compile for jansson that must exist\n    --------------+---------+-----------------------------------------------\n     tool         | (unset) | Auto detection\n                  | cjson   | Use cjson library\n                  | jsonc   | Use jsonc library\n                  | jansson | Use jansson library\n                  | none    | Don't compile the tool\n    --------------+---------+----------------------------------------------\n     libs         | (unset) | Like 'all'\n                  | all     | Like 'single' AND 'split'\n                  | single  | Only libmustach.so\n                  | split   | All the possible libmustach-XXX.so ...\n                  | none    | No library is produced\n\nThe libraries that can be produced are:\n\n     Library name       | Content\n    --------------------+--------------------------------------------------------\n     libmustach-core    | mustach.c mustach-wrap.c\n     libmustach-cjson   | mustach.c mustach-wrap.c mustach-cjson.c\n     libmustach-jsonc   | mustach.c mustach-wrap.c mustach-json-c.c\n     libmustach-jansson | mustach.c mustach-wrap.c mustach-jansson.c\n     libmustach         | mustach.c mustach-wrap.c mustach-{cjson,json-c,jansson}.c\n\nThere is no dependencies of a library to an other. This is intended and doesn't\nhurt today because the code is small.\n\n### Compilation Using Meson\n\nThanks to *qaqland* work, meson build is available. Please refer to **README.meson**.\n\n### Testing\n\nThe makefile offers the way to execute basic tests. Just type `make test`.\n\nBy default, if valgrind is available, tests are using it. It can be disabled\nby typing `make test valgrind=no` or `NOVALGRIND=1 make test`. Conversely,\nuse of valgrind can be enforced by typing `make test valgrind=yes` or\n`VALGRIND=1 make test`.\n\n## Extensions\n\nThe current implementation provides extensions to specifications of **mustache**.\nThis extensions can be activated or deactivated using flags.\n\nHere is the summary.\n\n     Flag name                     | Description\n    -------------------------------+------------------------------------------------\n     Mustach_With_Colon            | Explicit tag substitution with colon\n     Mustach_With_EmptyTag         | Empty Tag Allowed\n    -------------------------------+------------------------------------------------\n     Mustach_With_Equal            | Value Testing Equality\n     Mustach_With_Compare          | Value Comparing\n     Mustach_With_JsonPointer      | Interpret JSON Pointers\n     Mustach_With_ObjectIter       | Iteration On Objects\n     Mustach_With_EscFirstCmp      | Escape First Compare\n     Mustach_With_ErrorUndefined   | Error when a requested tag is undefined\n    -------------------------------+------------------------------------------------\n     Mustach_With_AllExtensions    | Activate all known extensions\n     Mustach_With_NoExtensions     | Disable any extension\n\nFor the details, see below.\n\n### Explicit Tag Substitution With Colon (Mustach_With_Colon)\n\nIn somecases the name of the key used for substitution begins with a\ncharacter reserved for mustach: one of `#`, `^`, `/`, `\u0026`, `{`, `\u003e` and `=`.\n\nThis extension introduces the special character `:` to explicitly\ntell mustach to just substitute the value. So `:` becomes a new special\ncharacter.\n\nThis is a core extension implemented in file **mustach.c**.\n\n### Empty Tag Allowed (Mustach_With_EmptyTag)\n\nWhen an empty tag is found, instead of automatically raising the error\nMUSTACH\\_ERROR\\_EMPTY\\_TAG pass it.\n\nThis is a core extension implemented in file **mustach.c**.\n\n### Value Testing Equality (Mustach_With_Equal)\n\nThis extension allows you to test the value of the selected key.\nIt allows to write `key=value` (matching test) or `key=!value`\n(not matching test) in any query.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Value Comparing (Mustach_With_Compare)\n\nThese extension extends the extension for testing equality to also\ncompare values if greater or lesser.\nIts allows to write `key\u003evalue` (greater), `key\u003e=value` (greater or equal),\n`key\u003cvalue` (lesser) and `key\u003c=value` (lesser or equal).\n\nIt the comparator sign appears in the first column it is ignored\nas if it was escaped.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Interpret JSON Pointers (Mustach_With_JsonPointer)\n\nThis extension allows to use JSON pointers as defined in IETF RFC 6901.\nIf active, any key starting with \"/\" is a JSON pointer.\nThis implies to use the colon to introduce JSON keys.\n\nA special escaping is used for `=`, `\u003c`, `\u003e` signs when\nvalues comparisons are enabled: `~=` gives `=` in the key.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Iteration On Objects (Mustach_With_ObjectIter)\n\nWith this extension, using the pattern `{{#X.*}}...{{/X.*}}`\nallows to iterate on fields of `X`.\n\nExample:\n\n- `{{s.*}} {{*}}:{{.}}{{/s.*}}` applied on `{\"s\":{\"a\":1,\"b\":true}}` produces ` a:1 b:true`\n\nHere the single star `{{*}}` is replaced by the iterated key\nand the single dot `{{.}}` is replaced by its value.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Error when a requested tag is undefined (Mustach_With_ErrorUndefined)\n\nReport the error MUSTACH_ERROR_UNDEFINED_TAG when a requested tag\nis not defined.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Access To Current Value\n\n*this was an extension but is now always enforced*\n\nThe value of the current field can be accessed using single dot.\n\nExamples:\n\n- `{{#key}}{{.}}{{/key}}` applied to `{\"key\":3.14}` produces `3.14`\n- `{{#array}} {{.}}{{/array}}` applied to `{\"array\":[1,2]}` produces ` 1 2`.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Partial Data First\n\n*this was an extension but is now always enforced*\n\nThe default resolution for partial pattern like `{{\u003e name}}`\nis to search for `name` in the current json context and\nas a file named `name` or if not found `name.mustache`.\n\nBy default, the order of the search is (1) as a file,\nand if not found, (2) in the current json context.\n\nWhen this option is set, the order is reverted and content\nof partial is search (1) in the current json context,\nand if not found, (2) as a file.\n\nThat option is useful to keep the compatibility with\nversions of *mustach* anteriors to 1.2.0.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n### Escape First Compare\n\nThis extension automatically escapes comparisons appears as\nfirst characters.\n\nThis is a wrap extension implemented in file **mustach-wrap.c**.\n\n## Difference with version 0.99 and previous\n\n### Extensions\n\nThe extensions can no more be removed at compile time, use\nflags to select your required extension on need.\n\n### Name of functions\n\nNames of functions were improved. Old names remain but are obsolete\nand legacy. Their removal in far future versions is possible.\n\nThe table below summarize the changes.\n\n     legacy name      | name since version 1.0.0\n    ------------------+-----------------------\n     fmustach         | mustach_file\n     fdmustach        | mustach_fd\n     mustach          | mustach_mem\n     fmustach_json_c  | mustach_json_c_file\n     fdmustach_json_c | mustach_json_c_fd\n     mustach_json_c   | mustach_json_c_mem\n     mustach_json_c   | mustach_json_c_write\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekgrpth%2Fmustach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frekgrpth%2Fmustach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekgrpth%2Fmustach/lists"}