How to use the ractive.parse function in ractive

To help you get started, we’ve selected a few ractive 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 ractive-foundation / ractive-foundation / dist / ractivef-cjs.js View on Github external
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);
		}
	}
github ractive-foundation / ractive-foundation / dist / ractivef-cjs.js View on Github external
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;
	},
github blackgate / ractive-componentify / lib / transform.js View on Github external
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-- ) {
github ractive-foundation / ractive-foundation / tasks / ractiveParse.js View on Github external
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();
    });
github ractive-foundation / ractive-foundation / tasks / documentation.js View on Github external
.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) {
github MartinKolarik / ractive-render / lib / template.js View on Github external
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));
github jrajav / ractivate / index.js View on Github external
function compile( file ) {

	return Ractive.parse( file )

}
github MartinKolarik / ractive-render / lib / utils.js View on Github external
return fs.readFileAsync(path.join(options.settings.views, options.wrapper), 'utf8').then(function (wrapper) {
		return injectTemplate(Ractive.parse(wrapper, options), options.el, template);
	});
};
github MartinKolarik / ractive-render / lib / utils.js View on Github external
return fs.readFileAsync(path.join(options.settings.views, partial.substr(8)) + rr.settings.extension, 'utf8').then(function (template) {
				return Ractive.parse(template, options);
			});
		}