Skip to content

Commit

Permalink
Added 'is_profane' template tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ReconCubed committed May 7, 2018
1 parent 67f65aa commit ca6ebde
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ At the top of every template you wish to use profanity filters and tags on, make
{% load profanity %}
...
```
##### Censor Tag
##### Censor Filter
###### Example
```jinja2
{% with string='You are a bitch!' %}
Expand All @@ -36,6 +36,14 @@ At the top of every template you wish to use profanity filters and tags on, make
```
The output will be `You are a *****!`, instead of `You are a bitch!`.

#### Is Profane Tag
##### Example
```jinja2
{% with string='You are a bitch!' %}
{{ string|is_profane }}
{% endwith %}
```
The output will be `True`, since the string contains profanity.

#### Validators
##### Is Profane Validator
Expand Down
2 changes: 1 addition & 1 deletion extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ def is_clean(self, input_text):

def is_profane(self, input_text):
""" Returns True if input_text contains any profane words, False otherwise. """
return self.has_bad_word(input_text)
return self.has_bad_word(input_text)
5 changes: 5 additions & 0 deletions templatetags/profanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
@register.filter()
def censor(value):
return pf.censor(value)


@register.filter()
def is_profane(value):
return pf.is_profane(value)

0 comments on commit ca6ebde

Please sign in to comment.