Skip to content
donnerjack13589 edited this page Aug 31, 2010 · 4 revisions

This is a standart module included with nTPL.

How to include it

require("./nTPL.filter");

Note that you must require nTPL before and nTPL.filter.js must be in your project’s folder.

Usage

Template

< div >
{%filter safe %}
< script >
  alert(" I am evil script! ");
</ script >
{%/filter %}
</ div>

Rendering this template will produce safe code, with brackets replace to &lt; and &gt; and other simple replacements.

Default filters list

  • safe
  • escape
  • lower
  • upper

Note: Escape will simply run escape function from javascript

How to add filters

nTPL.filters is exposed object that is holding all filters for this module.

nTPL.filters["my-filter-name"] = function ( str ) {
  return "_" + str + "_"
 }
Clone this wiki locally