escape(text,
quotes=True)
|
|
Create a Markup instance from a string and escape special characters
it may contain (<, >, & and ").
>>> escape('"1 < 2"')
<Markup u'"1 < 2"'>
If the quotes parameter is set to False , the " character is left
as is. Escaping quotes is generally only required for strings that are
to be used in attribute values.
>>> escape('"1 < 2"', quotes=False)
<Markup u'"1 < 2"'>
- Parameters:
text - the text to escape
quotes - if True, double quote characters are escaped in
addition to the other special characters
- Returns: Markup
- the escaped Markup string
|