Submitting patched version of sniplates.py (0.7.0) for your consideration for future releases.
Intent: to overcome 2 issues with 'nested_widget':
The name was not properly communicating its semantics/capabilities, and
It was not supporting injection of named blocks, only named variables. Named variables can prove awkward for injecting significant chunks of content.
Effects of modification:
Preserve backward compatibility
Introduce a new tag 'widblock'/'endwidblock', which is synonymous to 'nested_widget'/'endnested' but more concise, and uses the same NestedWidget class as nested_widget
Enhance NestedWidget to support context injection via named blocks inside a widblock (and nested_widget) body.
How this is done, in NestedWidget.render(), is:
pick out the block objects from the nodelist, render and save them separately
inject these block objects into the context under named keys, in the same way as the body content in the node gets injected under the key "content"
render the tag body into context key 'content' the same way as before, but without the nested blocks
Example usage:
{% widblock 'myapp:foo' %}
{% block introText %} ...add styled intro text, with links... {% endblock %}
{% block bodyGraph %} ...include a graph template... {% endblock %}
... optional body of this widget block, to be injected as variable 'content' ...
{% endwidblock %}
Thank you for your effort in developing, sharing and maintaining sniplates. I look forward to making heavy use of it in my current and future projects.
Submitting patched version of sniplates.py (0.7.0) for your consideration for future releases.
Intent: to overcome 2 issues with 'nested_widget':
Effects of modification:
How this is done, in NestedWidget.render(), is:
Example usage:
{% widblock 'myapp:foo' %} {% block introText %} ...add styled intro text, with links... {% endblock %} {% block bodyGraph %} ...include a graph template... {% endblock %} ... optional body of this widget block, to be injected as variable 'content' ... {% endwidblock %}
Thank you for your effort in developing, sharing and maintaining sniplates. I look forward to making heavy use of it in my current and future projects.
Cheers David (aum108 on freenode)
sniplatesCustom.py.txt