censor
Replaces a given list of words with nonsense characters.
Censor will replace a list of words with either asterisks (**), “cartoon nonsense” (@#&@), or redact blocks (███).
Sample Usage
{{ content|censor }}
This will output the value of {{ content }}
, with all words found in the word list replaced with one of the three types of replacements above.
Parameters
This modifier has one optional parameter, the type of replacement to be used. Allowed values are cartoon
, stars
, or redact
.
Configuring
This modifier comes with its own configuration file, found in _config/bundles/censor/censor.yaml
.
In here you can set word lists, characters used for replacement, as well as a global default for replacement type.
An example:
bad_word_segments:
- poop
bad_word_singles:
- meanie-face
- stupid-head
bad_word_segments
censor
will replace each of the words in this list no matter where they are found. Using “jump” as an example, “**** around” and “no ****ing on the couch”.
bad_word_singles
censor
will replace each of the words in this list only when they are used by themselves. Using “look” as an example, “don’t **** me over” versus “stop looking at me.”
replacement_mode
A way to globally set how censor
replaces words, options are cartoon
, stars
and redact
. This can be overridden with each use of the modifier by passing in the mode you want as the parameter. For example, if cartoon
is set globally, but you want to use stars
as a one-time thing, you can do: {{ some_swearing|censor:stars }}
leave_first_character
When replacing words, should the first letter be left behind, for those times when you want people to know what you’re saying, but don’t really want to say it. For example, “stupid” becomes “s*****.”
shuffle_replacement_characters: false
This setting applies to using cartoon
as the replacement_type
. When false
, censor will use the string in replacement_characters
as it is entered (repeating if needed). When true
, the characters in replacement_characters
will be randomly shuffled each time a word is replaced.
replacement_characters
This setting applies to using cartoon
as the replacement_type
. When words are replaced, these are the characters that will be used.