Add/rework the options for {% attr %} and {% definevar %}.

Review Request #9055 — Created July 5, 2017 and submitted

Information

Djblets
release-0.10.x
5e73690...

Reviewers

My recent change added some control over stripping to {% definevar %}
and made stripping mandatory for {% attr %}. This change builds upon
that by refining the behavior and adding more options.

{% attr %} now condenses the whitespace within the value by default
(turning sequences of spaces, tabs, and newlines into a single space).
All the new behavior can be turned off with the "nocondense" option.

It also now marks the value as unsafe, instead of making that the
caller's responsibility.

{% definevar %} now has a strip option for stripping
leading/trailing whitespace (replacing the new stripped), a
spaceless option for making the text spaceless (equivalent to wrapping
the value within as {% spaceless %}), and an unsafe option for
marking the value as unsafe.

Along with this (and to support these options), @blocktag now works with
template tags taking *args. When found, the check for the maximum number
of arguments will be turned off.

Unit tests passed.

Description From Last Updated

Maybe slightly more consistent to use mark_for_escaping?

daviddavid
david
  1. 
      
  2. Maybe slightly more consistent to use mark_for_escaping?

    1. Agreed in theory, but it's deprecated in Django and being removed in the next release. They're saying to convert to a string.

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (5d26a4a)
Loading...