Code

Opened 6 years ago

Closed 6 years ago

#8652 closed (wontfix)

Multiline tags and tag escape tags

Reported by: Michael Manfre <mmanfre@…> Owned by: nobody
Component: Template system Version: master
Severity: Keywords: escape multiline
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Multiline tag support would help make templates more readable and allow support for the ability to escape chunks of a template so that they are not parsed.

Multiline tag example:

{# This is a length comment that would benefit from multiple lines

due to its verbosity or some other reason #}

Tag escaping:
I have run in to the need to display template syntax to the end user. Being able to escape a chunk of the text so that the template parser ignores it would clean up the existing template. Some of the existing methods for passing template syntax through the parser unmolested is to use html entity escaping to trick the lexer, or use the very verbose "templatetag" tag.

Attached is a patch that provides the mentioned multiline tag support and provides tags that allow escaping blocks of template text.

Escaping example:

"{$ {% if foo %}...{% endif %} $}" would output "{% if foo %}...{% endif %}"

Attachments (1)

django-multiline-tags-with-no-raw-r8662.diff (2.1 KB) - added by Michael Manfre <mmanfre@…> 6 years ago.
Patch to add multiline tag support and escape tag syntax

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by Michael Manfre <mmanfre@…>

Patch to add multiline tag support and escape tag syntax

comment:1 Changed 6 years ago by jacob

  • milestone 1.0 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

We're quite a ways past feature freeze for 1.0;.

comment:2 Changed 6 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

Multi-line tags have been poo-pooed in the past (#3888) but I can see how it's important for this functionality.

Personally I'm -0 about the need for such a raw escape tag, but I'll pass it through a design decision.

comment:3 Changed 6 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

This looks a lot like two requests in one ticket and we all know how that isn't a good approach.

  1. Multiline template tags aren't going to happen. We've made a decision on that plenty of times.
  2. Adding a whole extra way to write template tags just to support this one particular use-case when you could just as easily write a shorter template tag for your own use is adding a bunch of maintenance overhead to Django for not a lot of gain. We have to keep the code correct, keep the documentation correct, explain it to people, incorporate the testing overhead, etc. Not worth it. If you have a need to do this a lot and don't want to write out "templatetag", write a shorter tag that calls templatetag internally. Or write a pre-processor for your templates. But this isn't worth adding code to Django for.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.