﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10107	Allow mark_safe() to be used as a decorator	matehat	Scott Vitale	"I think the two safety markers located in `django.utils.safestring` could be improved a bit to help DRYing up a redundant situation. Say some function of a model or whatever class instance is often used in templates and instead of applying the `safe` filter to it everywhere it appears in the template code, the returned value is marked as safe. Now the following pattern can be DRYed up:
{{{
def some_method(self, arg):
  if arg == 1:
    return mark_safe(some_tags)
  elif arg == 2:
    return mark_safe(some_other_tags)
  elif arg == 3:
    return mark_safe(some_third_tags)
}}}
Sure there are better ways to organize this type of pattern but it shows my point. Instead of appying the marker everywhere data is returned, it could be used as a decorator on the whole method:
{{{
@mark_safe
def some_method(self, arg):
  if arg == 1:
    return some_tags
  elif arg == 2:
    return some_other_tags
  elif arg == 3:
    return some_third_tags
}}}
Anyway, I made the necessary patch, so take a look at it! The same is applied to the `mark_for_escaping` method for the same reasons."	New feature	closed	Utilities	dev	Normal	fixed		mathieu.damours@… mmitar@… susan.tan.fleckerl@…	Accepted	1	0	0	0	0	0
