Skip to content

Commit

Permalink
Fix help text not rendering as "safe" (#93)
Browse files Browse the repository at this point in the history
* Revert "Removed |safe filter from help text (#66)"

This reverts commit 52156bf.
  • Loading branch information
Archmonger authored Jan 13, 2022
1 parent 8bccd51 commit 2b1a014
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crispy_bootstrap5/templates/bootstrap5/layout/help_text.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if field.help_text %}
{% if help_text_inline %}
<span id="hint_{{ field.auto_id }}" class="text-muted">{{ field.help_text }}</span>
<span id="hint_{{ field.auto_id }}" class="text-muted">{{ field.help_text|safe}}</span>
{% else %}
<small id="hint_{{ field.auto_id }}" class="form-text text-muted">{{ field.help_text }}</small>
<small id="hint_{{ field.auto_id }}" class="form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion tests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,5 @@ class HelpTextForm(forms.Form):
label="email",
required=True,
widget=forms.TextInput(),
help_text="Insert your email<>&",
help_text="Insert your <b>email</b>",
)
2 changes: 1 addition & 1 deletion tests/results/help_text_escape.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="mb-3" id="div_id_email"><label class="form-label requiredField" for="id_email">email<span
class="asteriskField">*</span></label><input class="form-control inputtext textInput textinput"
id="id_email" name="email" required type="text"><small class="form-text text-muted" id="hint_id_email">Insert
your email&lt;&gt;&amp;</small>
your <b>email</b></small>
</div>
2 changes: 1 addition & 1 deletion tests/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def test_flat_attrs_safe():
assert parse_form(form) == parse_expected("flat_attrs.html")


def test_help_text_escape():
def test_help_text_no_escape():
form = HelpTextForm()
form.helper = FormHelper()
form.helper.form_tag = False
Expand Down

0 comments on commit 2b1a014

Please sign in to comment.