Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Writing a Jinja2 filter... is it possible to make it automatically "safe"?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Haase  
View profile  
 More options Jun 15 2012, 10:16 am
From: Mark Haase <meha...@gmail.com>
Date: Fri, 15 Jun 2012 07:16:18 -0700 (PDT)
Local: Fri, Jun 15 2012 10:16 am
Subject: Writing a Jinja2 filter... is it possible to make it automatically "safe"?

A quick question about Jinja2 filters... I have auto escaping turned on, so
I have to use the safe filter to explicitly turn off escaping. I have
written a few filters that I know will always produce safe output, let's
call one of these "foo".

In my templates, I often do something like {{ my_var|foo }}, forgetting
that I need to add safe at the end, e.g. {{ my_var|foo|safe }}.

My question: is it possible for my foo filter to indicate that it's output
is already safe, so that it is not necessary to add the safe filter
explicitly?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Kryskalla  
View profile  
 More options Jun 15 2012, 10:32 am
From: Steven Kryskalla <skryska...@gmail.com>
Date: Fri, 15 Jun 2012 07:32:02 -0700
Local: Fri, Jun 15 2012 10:32 am
Subject: Re: Writing a Jinja2 filter... is it possible to make it automatically "safe"?

On Fri, Jun 15, 2012 at 7:16 AM, Mark Haase <meha...@gmail.com> wrote:
> My question: is it possible for my foo filter to indicate that it's output
> is already safe, so that it is not necessary to add the safe filter
> explicitly?

Try having the filter return a Markup object or an object with an
__html__ method.

http://jinja.pocoo.org/docs/api/#jinja2.Markup


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »