﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35535	"Provide new template tag to capture internal block output as a template variable (""simple block tag"")."	Jake Howard	Jake Howard	"Django's template system allows creating custom tags, but they don't allow taking content:

{{{#!django
{% mysimpletag foo=""bar"" %}
}}}

However there are plenty of use-cases where it'd be useful to also collect content along with the tag, turning it into a ""block"" tag:

{{{#!django
{% mysimpletag foo=""bar"" %}
  This content gets captured too
{% endmysimpletag %}
}}}

This currently requires using complex internals of the template system (some documented, some not) to achieve. The [https://github.com/django/django/blob/main/django/templatetags/cache.py cache tag] is a good example of this kind of ""simple"" block, which requires some parser internals.

I propose adding a `@register.simple_block` method to allow easy registering of custom block tags. The API would be similar to `simple_tag`, however with a required `content` argument containing the (rendered) template content:

{{{#!python
@register.simple_block(takes_context=True)
def mysimpletag(context: Context, content: str, foo: str) -> str:
    return f""foo = {foo}""
}}}

(Types added for reference)

I have a working demo of this I can push up."	New feature	closed	Template system	dev	Normal	fixed		Carlton Gibson Sébastien Corbin	Ready for checkin	1	0	0	0	0	0
