Skip to content

Instantly share code, notes, and snippets.

@JonCooperWorks
Created August 4, 2012 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonCooperWorks/3255178 to your computer and use it in GitHub Desktop.
Save JonCooperWorks/3255178 to your computer and use it in GitHub Desktop.
Boolean to Yes/No filter
@evalcontextfilter
def boolval2yesno(eval_ctx, value, true="Yes", false="No"):
if value:
result = true
else:
result = false
if eval_ctx.autoescape:
result = Markup(result)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment