How to use the ejs.render 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 contentjet / contentjet-api / src / viewsets / ProjectInviteViewSet.ts View on Github external
const projectInvite = await super.create(ctx);
    let token = await ProjectInvite.generateInviteToken(
      projectInvite.id, project.name, project.id
    );
    token = token.replace(/\./g, '~');
    const context = {
      url: url.resolve(config.FRONTEND_URL, `/accept-invite/${token}`),
      projectName: project.name,
      name
    };
    const mailOptions = {
      from: config.MAIL_FROM,
      to: email,
      subject: 'You have been invited to join a project',
      text: ejs.render(projectInviteTXT, context),
      html: ejs.render(projectInviteHTML, context)
    };
    this.options.mail.sendMail(mailOptions)
      .then(info => {
        console.log('Message sent: %s', info.messageId); // tslint:disable-line
      })
      .catch(err => {
        console.error(err);
      });
    return projectInvite;
  }
github fossasia / susper.com / node_modules / license-webpack-plugin / dist / LicenseWebpackPlugin.js View on Github external
.forEach(function (file) {
                            compilation.assets[file] = new webpack_sources_1.ConcatSource(ejs.render(_this.options.bannerTemplate, {
                                filename: outputPath,
                                licenseInfo: renderedFile.replace(/\*\//g, '') // remove premature comment endings
                            }), '\n', compilation.assets[file]);
                        });
                    }
github alibaba / ice / tools / iceworks-scaffolder / src / page / addPage.js View on Github external
if (!whetherContinue) {
      throw new Error('项目不存在模板文件,终止创建');
    }
  } else {
    templateData.blocks = material.getBlockComponentsPaths({
      cwd,
      name,
      blocks,
      preview,
    });
    logger.info('templateData', templateData);
    for (let file of scaffoldTemplate.page) {
      let templateContent = fs.readFileSync(file);
      templateContent = templateContent.toString();

      const outputTemplateContent = await ejs.render(templateContent, templateData, { async: true });

      let basename = path.basename(file).replace('.ejs', '');
      basename = material.parseFilename(basename, templateData);

      const pageOutput = './pages/' + pageFolderName;
      const clientFolder = getClientFolderName(nodeFramework);

      const outputFilePath = path.join(cwd, clientFolder, pageOutput, basename);
      logger.info('outputFilePath', outputFilePath);
      await write(outputFilePath, outputTemplateContent);

      pageResult.appendFiles(outputFilePath);
      pageResult.setOutput('page', pageOutput);
    }
  }
  return pageResult;
github vpapakir / uptime-openshift / plugins / patternMatcher / index.js View on Github external
dashboard.on('checkEdit', function(type, check, partial) {
    if (type !== 'http' && type !== 'https') return;
    partial.push(ejs.render(template, { locals: { check: check } }));
  });
github nordcloud / serverless-jest-plugin / lib / create-function.js View on Github external
const createAWSNodeJSFuncFile = (serverless, handlerPath) => {
  const handlerInfo = path.parse(handlerPath);
  const handlerDir = path.join(serverless.config.servicePath, handlerInfo.dir);
  const handlerFile = `${handlerInfo.name}.js`;
  const handlerFunction = handlerInfo.ext.replace(/^\./, '');
  let templateFile = path.join(__dirname, functionTemplateFile);

  if (serverless.service.custom &&
    serverless.service.custom['serverless-jest-plugin'] &&
    serverless.service.custom['serverless-jest-plugin'].functionTemplate) {
    templateFile = path.join(serverless.config.servicePath,
      serverless.service.custom['serverless-jest-plugin'].functionTemplate);
  }

  const templateText = fse.readFileSync(templateFile).toString();
  const jsFile = ejs.render(templateText, {
    handlerFunction,
  });

  const filePath = path.join(handlerDir, handlerFile);

  serverless.utils.writeFileDir(filePath);
  if (serverless.utils.fileExistsSync(filePath)) {
    const errorMessage = [
      `File "${filePath}" already exists. Cannot create function.`,
    ].join('');
    throw new serverless.classes.Error(errorMessage);
  }
  fse.writeFileSync(path.join(handlerDir, handlerFile), jsFile);

  const functionDir =
    handlerDir
github akashacms / akashacms / lib / renderer-ejs.js View on Github external
renderSync: function(text, metadata) {
	return ejs.render(text, metadata);
  },
  render: function(text, metadata, done) {
github hansemannn / hyperloop-robot / plugins / hyperloop / hooks / android / metabase / generate.js View on Github external
function generatePackage(packageDefinition) {
	return ejs.render(PACKAGE_TEMPLATE, {packageDefinition: packageDefinition});
}
github jaumesegarra / xtuff / generator.js View on Github external
fs.readFile(resourcePath, 'utf8', (err, data) => {
        if(err) onError('Error reading the file "'+file+'"', err, reject);

        try {
            global[utils.GLOBAL_CURRENT_EJS_FILE_CONTEXT] = {
                absoluteStuffPath,
                cacheStuffFolderPath,
                destinyPath
            };

            const component = ejs.render(data, {
                ...vars,
                "name": stuffName,
                ...patterns.list
            }, {delimiter: delimiter});

            const p = destinyPath.replace(new RegExp(EJS_EXTENSION+'$'), '');

            fs.writeFile(p, component);
            resolve();
        }catch(err){
            onError('Opss!', err, reject);
        }
    });
});
github TylorS / tempestjs / _scripts / new-package.js View on Github external
function renderEJS (TEMPLATE, data) {
  return EJS.render(fs.readFileSync(TEMPLATE, { encoding: 'utf-8' }), data, { delimiter: '%' })
}