First time here? Check out the FAQ!
0

Is there a way to escape the < character?

  • retag add tags

I'm trying to have some text bracketed with <> like: < option >
However, if I don't put a space between the first < and the word, it is interpreted as an html tag.

Is there a way to escape the < ?

It's not a big deal, just a cosmetic issue.

Benoit's avatar
875
Benoit
asked 2010-10-12 08:14:13 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

where do you need to escape it? If it's in the django or jinja template (askbot master branch already switched to jinja - if you need help with porting any of your custom templates - pls let me know), then use "escape" filter on values.

{{somevalue|escape}}

and it will do what @kraryal said automatically.

Evgeny's avatar
13.2k
Evgeny
updated 2010-10-12 12:10:10 -0500, answered 2010-10-12 12:09:56 -0500
edit flag offensive 0 remove flag delete link

Comments

Cool feature, but I don't think this would work right. I don't want to replace ALL instances of < I simply wanted a way to occasionally be able to write <option>. @kraryal provided a good way to do that.
Benoit's avatar Benoit (2010-10-13 07:20:29 -0500) edit
add a comment see more comments
1

To escape html characters, you usually want the & code for it.

For < use "&#60;" where you want "<".
For > use "&#62;" where you want ">".

This link has most of the characters. http://www.ascii.cl/htmlcodes.htm

kraryal's avatar
26
kraryal
answered 2010-10-12 10:08:06 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments