Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This small addition means it's possible to have
json2html
call itself mid-way through a render (without needing to use afunction()
). This allows for larger, fuller templates that have repeating sections within them (see example below).To use this feature, instead of specifying an
html
ortext
attribute, use the newsub
attribute and supply the location of the data for it and the template to render:The "sub" templates are of course the exact same format as the regular templates that json2html provides. The "data" attribute supplied to the "sub" gives the key to the data within that supplied to the
transform()
.Going further with templates and data, for example, this is possible:
And corresponding data such as:
This outputs something like:
The main points here being that you can have:
sub
feature)With this, since no actual function calls are used, it's also possible to send your template from place to place as a string (should such a requirement be necessary).