-
Type:
Bug
-
Status: To Do
-
Priority:
Medium
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Labels:None
I have an issue with how cfengine handles mustache templates.
The mustache engine renders sections when the value is a boolean or container.
This should be different:
- Render when (key resolves to value AND (value is true OR value is not empty list))
- This behaviour should be negatable by the '^' section attribute
As documented on: http://mustache.github.io/mustache.5.html
Sections Sections render blocks of text one or more times, depending on the value of the key in the current context. A section begins with a pound and ends with a slash. That is, {{#person}} begins a "person" section while {{/person}} ends it. The behavior of the section is determined by the value of the key. False Values or Empty Lists If the person key exists and has a value of false or an empty list, the HTML between the pound and slash will not be displayed.
http://mustache.github.io/#demo
Handles the mustache_example.json and mustache_example.mustache as expected; without exeptions.
The following unittest data seems to handle "Context Misses" correctly
core/tests/unit/data/mustache_sections.json
{ "name": "Context Misses", "data": {}, "expected": "[]", "template": "[{{#missing}}Found key 'missing'!{{/missing}}]", "desc": "Failed context lookups should be considered falsey." },
The following acceptance test expects the error "Mustache sections can only take a boolean..." to be thrown.
core/tests/acceptance/10_files/templating/mustache_section.cf
I have attached a diff. After applying:
- rebuild dir core/libutils
- rebuild dir core/libpromises
- replace/link libpromises.so
- relates to
-
CFE-2125 Mustache iterates over hashes when rendering
-
- Done
-