How to print html in python the normal way

Discussion in 'Python' started by ashishjain.ash@gmail.com, Oct 4, 2012.

  1. Guest

    Hi,

    I wrote a simple filter as:

    @register.filter()
    def html(value):
    return '<p>Check</p>'

    when I use this filter in my template, it displays html as:

    <p>Check</p>

    I want to display as:

    Check

    am I missing something.

    - Thanks for your help
    Ashish
     
    , Oct 4, 2012
    #1
    1. Advertising

  2. On Thu, Oct 4, 2012 at 9:24 PM, <> wrote:
    > am I missing something.


    The first thing you're missing is more detail in your question. My
    crystal ball tells me you're using some kind of web framework and
    viewing this in your browser. And my second crystal ball suggests that
    it's probably Django. But is this correct? Lots more detail, please!

    ChrisA
     
    Chris Angelico, Oct 4, 2012
    #2
    1. Advertising

  3. On Thursday, 4 October 2012 17:00:57 UTC+5:30, Chris Angelico wrote:
    > On Thu, Oct 4, 2012 at 9:24 PM, <> wrote:
    >
    > > am I missing something.

    >
    >
    >
    > The first thing you're missing is more detail in your question. My
    >
    > crystal ball tells me you're using some kind of web framework and
    >
    > viewing this in your browser. And my second crystal ball suggests that
    >
    > it's probably Django. But is this correct? Lots more detail, please!
    >
    >
    >
    > ChrisA


    +1
     
    Ramchandra Apte, Oct 4, 2012
    #3
  4. On Thursday, 4 October 2012 17:00:57 UTC+5:30, Chris Angelico wrote:
    > On Thu, Oct 4, 2012 at 9:24 PM, <> wrote:
    >
    > > am I missing something.

    >
    >
    >
    > The first thing you're missing is more detail in your question. My
    >
    > crystal ball tells me you're using some kind of web framework and
    >
    > viewing this in your browser. And my second crystal ball suggests that
    >
    > it's probably Django. But is this correct? Lots more detail, please!
    >
    >
    >
    > ChrisA


    +1
     
    Ramchandra Apte, Oct 4, 2012
    #4
  5. On Thu, Oct 4, 2012 at 9:11 AM, Ramchandra Apte <> wrote:
    > On Thursday, 4 October 2012 17:00:57 UTC+5:30, Chris Angelico wrote:
    >> On Thu, Oct 4, 2012 at 9:24 PM, <> wrote:
    >>
    >> > am I missing something.

    >>
    >>

    You should look at the built in django tags, and learn about them
    before writing your own

    In this case, look here:
    https://docs.djangoproject.com/en/dev/topics/templates/#filters


    striptags

    Strips all [X]HTML tags. For example:

    {{ value|striptags }}

    If value is "<b>Joel</b> <button>is</button> a <span>slug</span>",
    the output will be "Joel is a slug".

    Again, these are just a few examples; see the built-in filter
    reference for the complete list.



    --
    Joel Goldstick
     
    Joel Goldstick, Oct 4, 2012
    #5
  6. Guest

    Hi,

    Thanks for the reply.
    Apologies for my question not clear. Yes I am using django framework for it.

    - Regards
    Ashish
     
    , Oct 5, 2012
    #6
  7. Guest

    Hi,

    Thanks for the reply.
    Apologies for my question not clear. Yes I am using django framework for it.

    - Regards
    Ashish
     
    , Oct 5, 2012
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page