How to use the ejs.filters function in ejs

To help you get started, we’ve selected a few ejs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LaurentVB / mongoose-manager / lib / express.js View on Github external
app.engine('html', viewEngine);
    app.set('view engine', 'html');
    app.set('views', __dirname + '/../views');

    app.use(express.favicon());
    app.use(express.static(__dirname + '/../public', {'maxAge': 0}));
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(express.cookieParser(options.secret || 'mongoose manager cookie secret'));
    app.use(express.session());
    app.use(require('connect-flash')());
    app.use(require('../views/helpers').init(this));
    app.use(app.router);

    _.extend(require('ejs').filters, require('../views/filters'));

    // development only
    if ('development' == app.get('env')) {
        app.use(express.errorHandler());
    }

    return app;
};
github LockerProject / Locker / Apps / dashboardv3 / dashboard-client.js View on Github external
, github = false
  , githubLogin = ''
  , form = express.bodyParser
  , uistate = require(__dirname + '/uistate')
  , profileImage = 'img/default-profile.png'
  , path = require('path')
  , fs = require('fs')
  , im = require('imagemagick')
  , util = require("util")
  , lutil = require('lutil')
  , moment = require("moment")
  , page = ''
  , connectSkip = false
  ;

ejs.filters.capitalAll = function(obj) {
  return obj.map(function(word) {
    return word.charAt(0).toUpperCase() + word.substr(1);
  });
};

module.exports = function(passedLocker, passedExternalBase, listenPort, callback) {
  lconfig.load('../../Config/config.json');
  locker = passedLocker;
  app.listen(listenPort, function(){ callback(app.address().port); }); // pass back port actually used in case it was 0
};

var app = express.createServer();
app.use(express.cookieParser());

app.configure(function() {
  app.set('views', __dirname + '/views');
github baryon / node.blog / app.js View on Github external
app.dynamicHelpers({
    uri: function (req, res) {
        return req.url;
    },
    host: function (req, res) {
        return req.headers.host;
    },
    csrf_form_html: function (req, res) {
        return '<input value="' + req.session._csrf + '" name="_csrf" type="hidden">';
    },
    user: function (req, res) {
        return req.user;
    }
});

ejs.filters.trim = function (obj) {
    if (obj) return String(obj).replace(/^\s+|\s+$/g, "");
    else return '';
};

app.error(function(err, req, res, next){
	if( err == 403 ) {
        res.render('403');
    } else if( err == 404 ) {
        res.render('404');
    } else if( err == 500 ) {
        res.render('500');
    } else {
    	res.render('error', {errorCode : err});
        // next(err);
    }
});
github neo4j-contrib / neo4j-org / app.js View on Github external
return result;
    });
};

ejs.filters.blank = function (b) {
    return b || "";
};

ejs.filters.md = function (b) {
    return markdown(b)
};
ejs.filters.asciidoc = function (b) {
    return asciidoc.$render(b, null);
};

ejs.filters.wrap = function (content, tag) {
    return "&lt;" + tag + "&gt;" + content + "";
};

function dateFormat(d,time,tz) {
    var mthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    var dayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
    var zeroPad = function(number) {
        return ("0"+number).substr(-2,2);
    }
    return dayNames[d.getDay()]+" "+zeroPad(d.getDate())+" "+mthNames[d.getMonth()]+", "+ d.getFullYear() +
        (time ? (" "+ d.getHours()+":"+ zeroPad(d.getMinutes()) + (tz ? " "+tz:"")) : "");
}

app.locals({
    tutorial: {
        matrix: 'node:node_auto_index(id="603")',
github hexojs / hexo-generator-feed / feed.js View on Github external
var ejs = require('ejs'),
  merge = require('utils-merge'),
  path = require('path'),
  file = hexo.util.file2;

ejs.filters.cdata = function(str){
  return '';
};

var atomTmplSrc = path.join(__dirname, 'atom.ejs'),
  atomTmpl = ejs.compile(file.readFileSync(atomTmplSrc));

var rss2TmplSrc = path.join(__dirname, 'rss2.ejs'),
  rss2Tmpl = ejs.compile(file.readFileSync(rss2TmplSrc));

module.exports = function(locals, render, callback){
  var config = hexo.config;

  var feedConfig = merge({
    type: 'atom',
    limit: 20
  }, config.feed);
github neo4j-contrib / neo4j-org / app.js View on Github external
result.name = author['name'];
            result.twitter = author['twitter'] || (result.name.match(/\s/) ? "neo4j" : result.name);
        } else {
            result.name = author;
            result.twitter = result.name.match(/\s/) ? "neo4j" : result.name;
        }
        if (result.name.indexOf('@') == 0) {
            result.name = result.name.substring(1);
            result.twitter = result.name;
        }
        if (app.locals.contributors[result.name]) return app.locals.contributors[result.name];
        return result;
    });
};

ejs.filters.blank = function (b) {
    return b || "";
};

ejs.filters.md = function (b) {
    return markdown(b)
};
ejs.filters.asciidoc = function (b) {
    return asciidoc.$render(b, null);
};

ejs.filters.wrap = function (content, tag) {
    return "&lt;" + tag + "&gt;" + content + "";
};

function dateFormat(d,time,tz) {
    var mthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
github neo4j-contrib / neo4j-org / app.js View on Github external
result.twitter = result.name.match(/\s/) ? "neo4j" : result.name;
        }
        if (result.name.indexOf('@') == 0) {
            result.name = result.name.substring(1);
            result.twitter = result.name;
        }
        if (app.locals.contributors[result.name]) return app.locals.contributors[result.name];
        return result;
    });
};

ejs.filters.blank = function (b) {
    return b || "";
};

ejs.filters.md = function (b) {
    return markdown(b)
};
ejs.filters.asciidoc = function (b) {
    return asciidoc.$render(b, null);
};

ejs.filters.wrap = function (content, tag) {
    return "&lt;" + tag + "&gt;" + content + "";
};

function dateFormat(d,time,tz) {
    var mthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    var dayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
    var zeroPad = function(number) {
        return ("0"+number).substr(-2,2);
    }
github neo4j-contrib / neo4j-org / app.js View on Github external
result.name = result.name.substring(1);
            result.twitter = result.name;
        }
        if (app.locals.contributors[result.name]) return app.locals.contributors[result.name];
        return result;
    });
};

ejs.filters.blank = function (b) {
    return b || "";
};

ejs.filters.md = function (b) {
    return markdown(b)
};
ejs.filters.asciidoc = function (b) {
    return asciidoc.$render(b, null);
};

ejs.filters.wrap = function (content, tag) {
    return "&lt;" + tag + "&gt;" + content + "";
};

function dateFormat(d,time,tz) {
    var mthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    var dayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
    var zeroPad = function(number) {
        return ("0"+number).substr(-2,2);
    }
    return dayNames[d.getDay()]+" "+zeroPad(d.getDate())+" "+mthNames[d.getMonth()]+", "+ d.getFullYear() +
        (time ? (" "+ d.getHours()+":"+ zeroPad(d.getMinutes()) + (tz ? " "+tz:"")) : "");
}
github asdf2014 / yuzhouwan / yuzhouwan-blog / node_modules / hexo-generator-feed / feed.js View on Github external
var ejs = require('ejs'),
  merge = require('utils-merge'),
  path = require('path'),
  file = hexo.util.file2;

ejs.filters.cdata = function(str){
  return '';
};

var atomTmplSrc = path.join(__dirname, 'atom.ejs'),
  atomTmpl = ejs.compile(file.readFileSync(atomTmplSrc));

var rss2TmplSrc = path.join(__dirname, 'rss2.ejs'),
  rss2Tmpl = ejs.compile(file.readFileSync(rss2TmplSrc));

module.exports = function(locals, render, callback){
  var config = hexo.config;

  var feedConfig = merge({
    type: 'atom',
    limit: 20
  }, config.feed);