I’m using flask with a jinja2 template which includes another jinja2 template called buttons.html.
The parent of the buttons template looks like this:
{% include "{{ url_for('.buttons') }}" %}
The blueprint code looks like this:
@whatever_blueprint.route('/whatever/buttons.html', methods=['GET'])
def buttons():
return render_template('/whatever/buttons.html')
This allows me to take advantage of the fact that jinja will resolve the . prefixed url_for path to the current blueprint context and thus give me buttons rendered specifically for the blueprint in which this is rendered. I use the .prefix method in other cases, but haven’t tried the nested url_for in this context. Unfortunately, I can’t seem to get this to work, presumably because of the nested {% {{ }} %}.
Is this possible?
Unfortunately (or fortunately? most use-cases would be rather ugly) you cannot include URLs but only templates.
What you want is
{{ buttons() }}withbuttonsbeing thebuttonsfunction (or{{ buttons }}withbuttons=buttons()inrender_template()) passed to therender_template()call or made available via the global template context.