Ask Your Question
0

Is there a way to escape the < character?

asked 2010-10-12 08:14:13 -0600

Benoit gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2010-10-12 10:08:06 -0600

kraryal gravatar image

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

edit flag offensive delete link more
0

answered 2010-10-12 12:09:56 -0600

Evgeny gravatar image

updated 2010-10-12 12:10:10 -0600

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.

edit flag offensive delete link more

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 gravatar imageBenoit ( 2010-10-13 07:20:29 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-10-12 08:14:13 -0600

Seen: 128 times

Last updated: Oct 12 '10