Skip to content

Node.js based forum software built for the modern web

stripTags and escape template helpers

psychobunny789418f987cd
diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js
index dfecb7e78b..4aaef00a61 100644
--- a/public/src/modules/helpers.js
+++ b/public/src/modules/helpers.js
@@ -1,6 +1,6 @@
;(function(exports) {
"use strict";
- /* globals define */
+ /* globals define, utils */
// export the class if we are in a Node-like system.
if (typeof module === 'object' && module.exports === exports) {
@@ -9,6 +9,9 @@
var helpers = {};
+ var utils = utils || require('../utils'),
+ S = S || require('string');
+
helpers.displayMenuItem = function(data, index) {
var item = data.navigation[index],
properties = item.properties;
@@ -43,6 +46,14 @@
return JSON.stringify(obj).replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;").replace(/"/g, '&quot;');
};
+ helpers.escape = function(str) {
+ return utils.escapeHTML(str);
+ };
+
+ helpers.stripTags = function(str) {
+ return S(str).stripTags().s;
+ }
+
helpers.generateCategoryBackground = function(category) {
var style = [];