Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, function (require, exports, module) {
var Backbone = require("backbone")
, twig = require("twig").twig
// Load the template for a "Tweet"
// This template only needs to be loaded once. It will be compiled at
// load time and can be rendered separately for each Tweet.
, template = twig({
href: 'templates/tweet.twig'
, async: false
})
, TweetView = Backbone.View.extend({
tagName: "li"
, className: "tweet"
// Create the Tweet view
, initialize: function() {
// Re-render the tweet if the backing model changes
this.model.bind('change', this.render, this);
// Remove the Tweet if the backing model is removed.
this.model.bind('destroy', this.remove, this);
}
pathArray = pathArray.concat(elt[flatten]);
} else {
pathArray.push(elt);
}
}
}
for (i = 0, len = pathArray.length; i < len; i++) {
var tt = Twig.twig(merge(twigOpts,{path: template}));
// compute destination path by inserting '_n'
var destPath = dest.replace(/(.*)(\.[^\.]+)$/, replacer);
actualData.dataPath = pathArray[i];
grunt.file.write(destPath, tt.render(actualData));
}
actualData.dataPath = pathArray;
} else {
var twigTemplate = Twig.twig(merge(twigOpts,{path: template}));
grunt.file.write(dest, twigTemplate.render(actualData));
}
}
};
, function (require, exports, module) {
var twig = require("twig").twig
, Backbone = require("backbone")
, feed = require("feed").feed
// The application template
, template = twig({
href: 'templates/app.twig'
, async: false
})
, FeedView = require("feedView").FeedView
, feedView = new FeedView
, AppView = Backbone.View.extend({
tagName: "div"
, className: "app"
// Bind to the buttons in the template
, events: {
"click .reloadTweets": "reload"
, "click .changeUser": "changeUser"
, "click .twitter_user": "twitterLink"
if (!template.baseTemplate) {
// build baseTemplate form parent component
if (template.extendsFrom) {
let templateConfig = {};
if (hasBlocks(template.extendsFrom)) {
// use baseTemplate from parent component
const extendTemplate = templateRegistry.get(template.extendsFrom);
templateConfig = {
id: `${componentName}-baseTemplate`,
data: extendTemplate.baseTemplate.tokens
};
template.baseTemplate = Twig.twig(templateConfig);
} else if (template.overrides.length > 0) {
// use first override as baseTemplate
// and remove it from overrides
const firstOverride = template.overrides.shift();
template.baseTemplate = firstOverride;
} else {
warn(componentName, 'has no overrides or template to extend from!');
return '';
}
} else {
warn('missing baseTemplate', componentName);
return '';
}
}
function logAndRenderError(error) {
console.warn(error.message);
const template = Twig.twig({
data: '<p class="nitro-msg nitro-msg--error">{{ message }}</p>',
});
return template.render({ message: error.message});
}
.fcall(() => {
return twig
.twig({
allowInlineIncludes: true,
base: root_dir + '/platform/views',
path: root_dir + '/platform/views/' + template + '.twig',
async: false
})
.render(data);
});
}
function extractBlocks(file, content) {
const template = Twig.twig({
id: file.source.name,
data: content
});
const templateBlocks = template.render({}, {
output: 'blocks'
});
return Object.keys(templateBlocks).map((key) => {
const template = templateBlocks[key];
return {
name: key,
template: pretty(template, { ocd: true })
};
});
exports.get = (message, data) => {
const fileTemplate = fs.readFileSync(path.join(__dirname, 'messages', `${message}.twig`), 'utf8');
return Twig.twig({data: fileTemplate}).render(data);
};
exports.compile = function (content, options, fn) {
try {
const template = twig({
path: options.filepath,
base: path.dirname(options.filepath),
async: false
});
fn(null, template.render(options));
} catch (err) {
err.filepath = options.filepath;
fn(err);
}
};
},
description: {
start: '',
end: '',
twig: Twig.twig({
data: fs.readFileSync(path.join(__dirname, '/template_description.md'), 'utf-8')
}),
generate: (packageJSON, directory) => {
let description = wrap(packageJSON.description)
return stripHtmlComments(tags.description.twig.render({ packageDescription: description }))
}
},
install: {
start: '',
end: '',
twig: Twig.twig({
data: fs.readFileSync(path.join(__dirname, '/template_install.md'), 'utf-8')
}),
generate: (packageJSON, directory) => {
return stripHtmlComments(tags.install.twig.render({ packageName: packageJSON.name }))
}
},
dependencygraph: {
start: '',
end: '',
twig: Twig.twig({
data: fs.readFileSync(path.join(__dirname, '/template_dependency_graph.md'), 'utf-8')
}),
generate: (packageJSON, directory) => {
let dependencyGraph = ''
let deps = []
for (let key in packageJSON.dependencies) {