Ticket #4984 enhancement new

Opened 2 years ago

Last modified 2 years ago

twisted.web.template needs passthrough technique.

Reported by: jerub Owned by: jerub
Priority: normal Milestone:
Component: web Keywords:
Cc: jknight Branch:
Author: Launchpad Bug:

Description

It is sometimes useful to do something along the lines of:

blob_of_rendered_html = someFunction()
return tags.html(tags.body(blob_of_rendered_html))

But it is not possible to get a str, or some kind of subclass of str, through _flattenString() or _flattenTree() without being modified.

Change History

1

  Changed 2 years ago by DefaultCC Plugin

  • cc jknight added

2

follow-up: ↓ 3   Changed 2 years ago by exarkun

  • owner set to jerub

Passing through arbitrary strings is a good way to generate invalid output, potentially with security issues.

If you really need to put some HTML (or XML or what have you) into the result, you can parse it into tags and then put the tag tree into the output and it will be reflattened for you.

I think we should consider this feature carefully and not just assume it's something to include.

3

in reply to: ↑ 2   Changed 2 years ago by glyph

Replying to exarkun:

If you really need to put some HTML (or XML or what have you) into the result, you can parse it into tags and then put the tag tree into the output and it will be reflattened for you.

Also, if we implement template precompilation, you only need to pay this parsing cost once (assuming you cache the result). So perhaps we should do that first, then revisit this if there are still use-cases for it unsatisfied by that performance improvement?

Note: See TracTickets for help on using tickets.