Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function render(options) {
mustache.tags = options.tags.split(',');
return Promise.all([
// Read the template
readTemplate(options),
getReferencesPaths(options),
getInlinedFilesContents(options),
]).then(function(results) {
var template = results[0];
var pathsByExtension = results[1];
var contentsByExtension = results[2];
var locales = extend({}, pathsByExtension, contentsByExtension);
return mustache.render(template, locales);
});
}
function loadPartials(template, templatePath) {
var templateDir = path.dirname(templatePath)
var partialRegexp = new RegExp(
escapeRegex(mustache.tags[0]) +
'>\\s*(\\S+)\\s*' +
escapeRegex(mustache.tags[1]),
'g'
)
var partialMatch
while ((partialMatch = partialRegexp.exec(template))) {
var partialName = partialMatch[1]
if (!partials[partialName]) {
try {
var partialPath = null
var partial = null
// ignore `partial` with file extension.
// e.g.
// 1, `{{> ./path/to/partial.html }}`
// 2, `{{> ./path/to/partial. }}`
module.exports = function(view, options, partials) {
options = options || {}
partials = partials || {}
var viewError = null
if (options.tags) {
mustache.tags = options.tags
}
// if view is string, interpret as path to json filename
if (typeof view === 'string') {
try {
view = JSON.parse(fs.readFileSync(view, 'utf8'))
} catch (e) {
viewError = e
}
}
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
this.push(file)
return cb()
}
const fs = require('fs');
const inquirer = require('inquirer');
const extend = require('extend');
const copyfiles = require('copyfiles');
const glob = require('glob');
const mustache = require('mustache');
const utils = require('./utils.js');
const rawQuestions = require('./questions.js');
mustache.tags = ['<%', '%>'];
const globalDependencies = utils.allDependencies(JSON.parse(fs.readFileSync('./package.json')));
function prompt(questions) {
// eslint-disable-next-line no-use-before-define
return inquirer.prompt(questions).then(handleAnswers);
}
function create(config) {
const source = `./_templates/${config.type}`;
const dest = `./packages/node_modules/${config.name}`;
const sourceGlob = `${source}/**/*.*`;
const destGlob = `${dest}/**/*.*`;
const renderdata = extend({}, config);
renderdata.name = { original: config.name };
function staticGen(file, opts) {
opts = _.isObject(opts) ? opts : {};
mustache.tags = config.templateTags;
partials = (!partials || opts.shouldGetPartials) ? getPartials() : partials;
lambdas = (!lambdas || opts.shouldGetLambdas) ? getLambdas(opts.shouldGetLambdas) : lambdas;
const {src, data: dataPath, wrapperData: wrapperDataPath} = file;
const wrapper = _.has(file, 'wrapper') ? fs.readFileSync(file.wrapper, 'utf8') : '';
const page = fs.readFileSync(src, 'utf8');
const dataRef = cache.get('files', dataPath);
const data = _.get(dataRef, 'content');
const wrapperDataRef = cache.get('files', wrapperDataPath);
const wrapperData = _.get(wrapperDataRef, 'content');
const templateData = _.assign({}, wrapperData, data, {lambdas});
if (_.has(wrapperData, 'assets') && _.has(data, 'assets')) {
templateData.assets = _.mergeWith({}, wrapperData.assets, data.assets, (dest, src) => {
return [dest, src].every(_.isArray) ? _.union(dest, src) : undefined;
SystemJS.import(this.configurationPath()).then((setup) => {
setup.default(this);
Mustache.tags = [this.start, this.end];
utils.info(this.introduction);
inquirer.prompt(this.questions).then((answers) => {
this.input = answers;
this.readTemplateFilePaths().then((files) => {
const filtered = files.filter(file => this.shouldRender(file));
Promise.map(filtered.filter(file => fse.statSync(file).isFile()), (file) => {
this.renderFile(file, path.resolve(output, path.relative(this.path(), file)));
}).then(() => {
utils.info(this.summary(this.input));
resolve();
});
});
});
}).catch(winston.error);
});
System.import(this.configurationPath()).then((setup) => {
setup.default(this);
Mustache.tags = [this.start, this.end];
utils.info(this.introduction);
inquirer.prompt(this.questions).then((answers) => {
this.input = answers;
this.readTemplateFilePaths().then((files) => {
const filtered = files.filter(file => this.shouldRender(file));
Promise.map(filtered.filter(file => fse.statSync(file).isFile()), (file) => {
this.renderFile(file, path.resolve(output, path.relative(this.path(), file)));
}).then(() => {
utils.info(this.summary(this.input));
resolve();
});
});
});
});
});
function render(templatePath, viewDirectory, extension, options, cache, tags, callback) {
if (callback === undefined && typeof tags === 'function') {
callback = tags;
tags = mustache.tags;
} else if (tags === undefined) {
tags = mustache.tags;
}
loadTemplateAndPartials(templatePath, viewDirectory, extension, options, cache, tags, function(err, template, partials) {
if (err) {
return callback(err);
}
var data = mustache.render(template, options, partials, tags);
return callback(null, data);
});
}
const path = require('path');
const fs = require('fs');
const glob = require('glob');
const markdownMagic = require('markdown-magic');
const mustache = require('mustache');
const dfs = require('depth-first').default;
mustache.tags = ['<%', '%>'];
const disclaimerMD = fs.readFileSync(path.join(__dirname, 'DISCLAIMER.md'), 'utf-8');
function createConfig(moduleName, edges) {
return {
transforms: {
DISCLAIMER() {
const renderdata = { name: moduleName };
return mustache.render(disclaimerMD, renderdata);
},
INSTALL() {
const dependencies = dfs(edges, moduleName).sort().join(' ');
return [
'### Installering:',
'```',
`npm install ${dependencies} --save`,
'```'