Default Helpers¶
Helpers provide utility functions and classes for templates.
Any loaded template library can provide additional helpers.
-
knights.helpers.stringfilter(func)¶ A decorator which ensures the first argument to func is cast as a str()
The default set of helpers are as follows:
-
knights.helpers.addslashes(value)¶ Escape , ”, and ‘ characters by placing a before them.
-
knights.helpers.capfirst(value)¶ Capitalise only the first character of the string.
-
knights.helpers.escape(value, mode='html')¶ Escape unsafe characters in the string.
By default applies HTML escaping on &, <, >, ” and ‘ characters, using HTML entities instead.
Also supports ‘js’ mode.