-4

hey so i'm storing a string like '<h1>test</h1><br><br><h1>yep</h1>' in a table then displaying the result on my webserver, the problem is that the string is exactly that, i'm trying to make it so it will acutally use the h1 tag in the source.

the type of the column i'm storing it in is text, i'm using mako templating system and pyramid web framework

heres what im getting:

what i dont want

here's what i want it to look like

what i want

i'm just using a textarea tag to input data into the table.

edit: how i'm adding the string into the db

    post_subject = request.params.get("subject")
    post_message = request.params.get("message")
    # some other stuff .....
    cur.execute("\
        INSERT INTO bulbs_Post (subcategory_id, parent_post, title, content, date, user_id, ip) VALUES \
        (%s, %s, %s, %s, now(), %s, %s)", (forum_id, parent_id, post_subject, post_message, user_id, request.client_addr))

i'm displaying the content in the template by using ${post_content}

CrackSmoker9000
  • 319
  • 4
  • 13

2 Answers2

0

Alright I have figured it out, turns out when displaying the content mako was filtering the data anyways. I was able to declare the variable safe using ${post_content | n}

http://docs.makotemplates.org/en/latest/filtering.html#turning-off-filtering-with-the-n-filter

CrackSmoker9000
  • 319
  • 4
  • 13
-1

Your string is wrong. Use the following string -

<h1>test</h1><br><br><h1>yep</h1>
Subha
  • 1,051
  • 1
  • 6
  • 12