How to use the ejs.close 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 vpetrov / survana / index.js View on Github external
*/

var express =   require('express'),
    DB      =   require('./db'),
    sconfig =   require("./config"),
    log     =   require('logule').init(module),
    path    =   require('path'),
    ejs     =   require('ejs'),
    ursa    =   require('ursa'),
    fs      =   require('fs'),
    util    =   require('./util'),
    //constants
    HTTP_SERVER_ERROR = 500;

ejs.open    =   '{{';
ejs.close   =   '}}';

/* Globals */
global.obj          =   require('./lib/obj');
global.arrays       =   require('./lib/arrays');
global.ClientError  =   require('./lib/clienterror');
global.ROOT         =   path.dirname(process.mainModule.filename);

/**
 * Mount a new Survana module
 * @param app
 * @param name
 * @param mconf
 * @return {Object}
 */
function addModule(app,name,mconf)
{
github prismic-archive / baked.js / src / baked.js View on Github external
function renderTemplate(content, ctx) {
    // The vm context sandbox is kept separate from the template context to work around an issue
    // in earlier versions of node (pre v0.11.7) where escape() is added to the template context.
    if (!ctx._sandbox) {
      ctx._sandbox = vm.createContext(ctx);
    }
    ejs.open = '[%';
    ejs.close = '%]';
    ctx._sandbox.__render__ = function render() {
      delete ctx._sandbox.__render__;
      return ejs.render(content, ctx);
    };

    return vm.runInContext("__render__()", ctx._sandbox);
  }
github xiaoqiang-zhao / cellar / tool / publish / lib / init-article-detail-page.js View on Github external
/**
 * 初始化每篇文章的详情页和数据片段
 * (采用同步处理,因为后续操作需要依赖此结果)
 *
 * Created by zhaoxiaoqiang on 15/10/23.
 */
var fs = require('fs');
var ejs = require('ejs');
// 当和 init-site 集成使用时需要重置配置
ejs.open = '<%';
ejs.close = '%>';
var config = require('./config.js');
var markdownTool = require('./markdown-tool.js');
/**
 * 初始化每篇文章的详情页和数据片段
 * (采用同步处理)
 *
 * @param {Array} articleArr 文章列表
 */
function initArticleDetail (articleArr) {
    var articleDetailTemplatePath = config.rootPath + config.articleDetailPageTemplatePath;
    var articleDetailTemplateStr = fs.readFileSync(articleDetailTemplatePath, config.encoding);

    articleArr.forEach(function (article) {
        var mdFilePath = article.folderPath + '/' + config.mdFileFilename;
        var mdContent = fs.readFileSync(mdFilePath, config.encoding);
        var markedData = markdownTool.mark(mdContent);
github xiaoqiang-zhao / cellar / tool / publish / lib / init-index-page.js View on Github external
/**
 * 初始化页面
 *
 * Created by zhaoxiaoqiang on 15/10/19.
 */

var fs = require('fs');
var config = require('./config.js');
var ejs = require('ejs');
// 当和 init-site 集成使用时需要重置配置
ejs.open = '<%';
ejs.close = '%>';

function initPage(articleArr) {
    // 首页
    var indexPageTemplatePath = config.rootPath + config.indexPageTemplatePath;
    var indexTemplate = fs.readFileSync(indexPageTemplatePath, config.encoding);
    var indexHtml = ejs.render(
        indexTemplate,
        {
            articleArr: articleArr
        }
    );
    var indexPagePath = config.rootPath + config.indexPagePath;
    fs.writeFileSync(indexPagePath, indexHtml, config.encoding);
}

module.exports = initPage;
github visionmedia / connect-render / lib / render.js View on Github external
*/

var fs = require('fs');
var path = require('path');
var http = require('http');
var ejs = require('ejs');
var filters = require('./filters');

var settings = {
  root: __dirname + '/views',
  cache: true,
  layout: 'layout.html',
  viewExt: '', // view default extname
  _filters: {},
  open: ejs.open || "<%",
  close: ejs.close || "%>"
};

for (var k in filters) {
  settings._filters[k] = filters[k];
}

var cache = {};

function _render_tpl(fn, options, callback) {
  var str;
  try {
    str = options.scope ? fn.call(options.scope, options) :  fn(options);
  } catch (err) {
    return callback(err);
  }
  callback(null, str);
github bhtz / microscopejs / lib / scaffolders / viewsScaffolder.js View on Github external
function ViewScaffolder(){
		ejs.open = '{{';
		ejs.close = '}}';
	};
github bhtz / microscopejs / lib / utils.js View on Github external
Utils.prototype.writeTemplateFileSync = function(destinationFile, templatePath, model, ejsOpenTag, ejsCloseTag) {
		ejs.open = '{{';
		ejs.close = '}}';
		this.writeFileSync(destinationFile, templatePath, model);
	};
github makarukudo / nodeigniter / node_modules / nodeigniter / lib / nodeigniter.js View on Github external
this.render = function() {
        var ejs = require('ejs');
        ejs.open = '{{';
        ejs.close = '}}';
        var opts = utils.merge(self.locals, self.fn);
        self.output = ejs.render(self.output, opts);
        self.res.end(self.output, 'utf-8');
        self.output = '';
    }
github xiaoqiang-zhao / cellar / tool / init-site / lib / main.js View on Github external
function renderTemplateAndCopy(item) {
    var fromPath = libPath + item.from;
    var toPath = rootPath + item.to;
    var template = fs.readFileSync(fromPath, encoding);
    if (typeof item.before === 'string') {
        template = item.before + template;
    }

    ejs.open = '{{';
    ejs.close = '}}';
    var content = ejs.render(
        template,
        config.siteData
    );
    fs.writeFileSync(toPath, content, encoding);
}