Permalink
Browse files

move filters from window to jst

  • Loading branch information...
1 parent fbc2f32 commit 081f91548b791565f836f5598d36553f13b285bd @shaunlee committed Mar 13, 2012
Showing with 28 additions and 30 deletions.
  1. +28 −30 jst.js
View
58 jst.js
@@ -4,51 +4,49 @@
* MIT Licensed
*/
-// filters
+// compiler
-var filters = {};
+var jst = {};
;(function(exports) {
var htmlCodes = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;'},
htmlre = /&(?!\w+;)|<|>|"/g,
htmlEscape = function (src) { return htmlCodes[src]; },
- linere = /(\r\n|\r|\n)/g;
-
- exports.convert = function(src) {
- return src.split('|').reduce(function(varname, filter) {
- return 'filters.' + filter + '(' + varname + ')';
- });
- }
-
- exports.e = exports.escape = function(src) {
- return typeof src !== 'string' ? src : src.replace(htmlre, htmlEscape);
- }
+ linere = /(\r\n|\r|\n)/g,
+ //
+ _cache = {},
+ _options = {
+ useIt: false
+ };
- exports.linebreaks = function(src) {
- return '<p>' + src.split(/\r\n|\n/g).join('</p><p>') + '</p>';
- }
+ var filters = exports.filters = {};
- exports.linebreaksbr = function(src) {
- return src.replace(linere, '<br>$1');
- }
+ (function(exports) {
- exports.add = function(value) {
- return function(src) { return Number(value) + Number(src); };
- }
+ exports.convert = function(src) {
+ return src.split('|').reduce(function(varname, filter) {
+ return 'filters.' + filter + '(' + varname + ')';
+ });
+ }
-})(filters);
+ exports.e = exports.escape = function(src) {
+ return typeof src !== 'string' ? src : src.replace(htmlre, htmlEscape);
+ }
-// compiler
+ exports.linebreaks = function(src) {
+ return '<p>' + src.split(/\r\n|\n/g).join('</p><p>') + '</p>';
+ }
-var jst = {};
+ exports.linebreaksbr = function(src) {
+ return src.replace(linere, '<br>$1');
+ }
-;(function(exports) {
+ exports.add = function(value) {
+ return function(src) { return Number(value) + Number(src); };
+ }
- var _cache = {},
- _options = {
- useIt: false
- };
+ })(exports.filters);
exports.addFilter = function(name, fn) {
filters[name] = fn;

0 comments on commit 081f915

Please sign in to comment.