Ticket #8966: 8966_with_docs.diff
File 8966_with_docs.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/template/defaultfilters.py
476 476 def length_is(value, arg): 477 477 """Returns a boolean of whether the value's length is the argument.""" 478 478 return len(value) == int(arg) 479 length_is.is_safe = True480 479 481 480 def random(value): 482 481 """Returns a random item from the list.""" -
docs/howto/custom-template-tags.txt
241 241 this tricky, but keep an eye out for any problems like that when 242 242 reviewing your code. 243 243 244 Marking a filter ``is_safe`` will coerce the filter's return value to 245 a string. If your filter should return a boolean or other non-string 246 value, marking it ``is_safe`` will probably have unintended 247 consequences (such as converting a boolean False to the string 248 'False'). 249 244 250 2. Alternatively, your filter code can manually take care of any necessary 245 251 escaping. This is necessary when you're introducing new HTML markup into 246 252 the result. You want to mark the output as safe from further