Internally choosing how to process a template is inconsistent
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
inclusion_tag checks the following:
- Is it a Template instance?
- Or is it not a string, and is it iterable? is_iterable would allow genexps/dictionaries through
- Both the above failed? Should be a string.
render_to_string checks the following:
- is it a list or tuple? doesn't allow genexps/dictionaries/etc
- No? It must be a string
- doesn't account for being passed a Template instance at all
SimpleTemplateResponse checks the following:
- is it a list or a tuple (consistent with render_to_string)
- No; is it a string? (consistent with render_to_string)
- No; ok, it must be a template instance (inconsistent with render_to_string, sort of consistent with inclusion_tag)
I discovered this while trying to choose how to fix #20995, which would again be different; I don't really want to push a pull request for that one without knowing what the outcome of this is, though. It might be worth introducing a single function (
resolve_template or something) which provides a consistent way to take an input and decide how to get from it to a Template instance.
Change History (5)
comment:1 Changed 3 years ago by
|Component:||Uncategorized → Template system|
|Patch needs improvement:||unset|
|Type:||Uncategorized → Cleanup/optimization|
|Version:||1.5 → master|