Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onconfig: function () {
var datamodel = this.get('datamodel');
if (datamodel) {
// For datamodel driven components, the tab content can be html containing more ux components.
// Therefore, we have to evaluate this, so we do that by injecting a partial here.
// See http://docs.ractivejs.org/latest/partials#updating
this.partials.dynamicContent = Ractive.parse(datamodel.content);
}
}
initInstance: function (container) {
// Have we mixed in extensions to all instances yet?
if (!Ractive.prototype.findAllChildComponents) {
_.mixin(Ractive.prototype, RactiveF.mixins);
}
var instance = new Ractive({
el: container,
template: Ractive.parse(container.innerHTML),
components: RactiveF.components,
onrender: function () {
this.el.classList.remove('hide');
this.el.classList.add('initialize');
}
});
instance.on('*.*', RactiveF.genericEventHandler);
instance.set('dataModel', '{{dataModel}}');
return instance;
},
module.exports = function tranform (url, source) {
var parsed = Ractive.parse(source, {
noStringify: true,
interpolate: { script: false, style: false },
includeLinePositions: true
});
var links = [];
var styles = [];
var scriptItem;
// Extract certain top-level nodes from the template. We work backwards
// so that we can easily splice them out as we go
var template = parsed.t;
var i = template.length;
while ( i-- ) {
var stream = through.obj(function (file, enc, callback) {
if (file.isStream()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
return callback();
}
var componentName = file.history[0].split(path.sep).slice(-2)[0];
var filecontents = '';
try {
filecontents = String(file.contents);
//Parse template in Ractive
filecontents = Ractive.parse(filecontents, options);
filecontents = JSON.stringify(filecontents);
filecontents = options.prefix + '[\'' + componentName + '\'] = ' + filecontents + ';';
file.contents = new Buffer(filecontents);
this.push(file);
}
catch (e) {
console.warn('Error caught from Ractive.parse: ' +
e.message + ' in ' + file.path + '. Returning uncompiled template');
this.push(file);
return callback();
}
callback();
});
.then(function(partials) {
var template = Ractive.parse(fs.readFileSync(options.template, 'UTF-8'), options);
return new Ractive({
template: template,
partials: partials,
data: {},
delimiters: options.delimiters,
tripleDelimiters: options.tripleDelimiter
});
})
.catch(function(err) {
return fs.readFileAsync(file, 'utf8').then(function (template) {
return utils.wrap(Ractive.parse(template, options), options);
}).then(function (template) {
var basePath = path.relative(options.settings.views, path.dirname(file));
function compile( file ) {
return Ractive.parse( file )
}
return fs.readFileAsync(path.join(options.settings.views, options.wrapper), 'utf8').then(function (wrapper) {
return injectTemplate(Ractive.parse(wrapper, options), options.el, template);
});
};
return fs.readFileAsync(path.join(options.settings.views, partial.substr(8)) + rr.settings.extension, 'utf8').then(function (template) {
return Ractive.parse(template, options);
});
}