Every line of 'ejs render' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
6 function ejsRenderer(data, locals) { 7 return ejs.render(data.text, assign({filename: data.path}, locals)); 8 }
29 function render(range, templateContent, data) { 30 debug("Rendering template"); 31 return ejs.render(templateContent, Object.assign({ 32 range: range, 33 dateFnsFormat: dateFnsFormat 34 }, data)); 35 }
14 function ejs2html(ejsName, ejsFolder) { 15 var htmlPath = '/public/', 16 ejsPath = __dirname + ejsFolder + ejsName; 17 i18n.setLocale('ch'); 18 htmlPath = __dirname + htmlPath; 19 if(!fs.existsSync(htmlPath)) { 20 fs.mkdirSync(htmlPath); 21 } 22 ejs.renderFile(ejsPath, { 23 url: url, 24 cdnUrl: cdnUrl 25 }, function (err, result) { 26 if(!err) { 27 var htmlName = ejsName.replace('.ejs', '.html'); 28 fs.writeFile(htmlPath + htmlName, result, function () {}); 29 } else { 30 /*eslint no-console: ["error", { allow: ["log"] }] */ 31 console.log(err); 32 } 33 }); 34 }
77 function renderJs(rawScript, render) { 78 const { matches, script } = findInjectionPosition(rawScript); 79 80 if (matches && matches.length) { 81 let renderScript = `module.exports={\n render: ${render.render},\n\n staticRenderFns: ${render.staticRenderFns}, \n`; 82 83 return script 84 .split(matches[1]) 85 .join( 86 renderScript.replace('module.exports={', matches[1]).replace(/\}$/, '') 87 ); 88 } 89 90 throw new Error(`cannot find 'export defaults'.`); 91 }
94 render() { 95 const kind = (this.node.kindString || '').toLowerCase(); 96 this.node.filename = this.templates[kind].filename; 97 this.node.tsHelpers = TSHelper; 98 // HACK: for some reason "comment" is not getting passed in EJS include 99 // May be it is a keyword and treated differently, should copy it in 100 // to another variable comment_copy that gets passed on to included template. 101 this.node.comment_copy = this.node.comment; 102 return ejs.render(this.templates[kind].content, this.node); 103 }
5 export function render(templateName, options) { 6 // TODO: add cache for templates and read files async 7 const template = readFileSync( 8 path.join(__dirname, `/templates/${templateName}.md`), 9 { 10 encoding: 'utf8', 11 }, 12 ); 13 14 return ( 15 ejs 16 .render(template, options) 17 // trip line break at the beginning 18 .replace(/^\n+/g, '') 19 // make sure that you have only one line break at the end 20 .replace(/\n+$/g, '\n') 21 // replace more then 2 line break for 2 22 .replace(/[\n]{2,}/g, '\n\n') 23 ); 24 }