Template engine: a nesting issue I face
-
Hi,
I am still wondering if what I found is a valid bug or not.
When I try to test the template engine using the given example below, it works fine.{ "animals": [ { "name": "Cat", "species": "Felis silvestris catus", "isHuman": false, }, { "name": "Dog", "species": "Canis lupus familiaris", "isHuman": false, }, { "name": "Human", "species": "Homo sapiens", "isHuman": true } ], "package": { "name": "templates.js", "author": "psychobunny", "url": "http://www.github.com/psychobunny/templates.js" }, "website": "http://burnaftercompiling.com", "sayHello": true }
<!-- BEGIN animals --> {animals.name} is from the species {animals.species}. <!-- END animals -->
After that, I had the animals moved under another field 'living' as a child as noted below:
{ "living": { "animals": [ { "name": "Cat", "species": "Felis silvestris catus", "isHuman": false, }, .... ] }
For this JSON data, the following doesn't print out anything:
<!-- BEGIN living.animals --> {living.animals.name} is from the species {living.animals.species}. <!-- END living.animals -->
Is this a known limitation or a bug? Am I missing something here?
Thanks
-
@baris said:
Does this work?
<!-- BEGIN animals --> {living.animals.name} is from the species {living.animals.species}. <!-- END animals -->
Thanks for your reply. I tried it and it works!
Is that the intended use? What if another 'animals' is also there under a different node within the same json document? -
@thinkdiff said:
You can report bugs you find to the templates.js repo as well. https://github.com/psychobunny/templates.js/issues
Copyright © 2024 NodeBB | Contributors