How to use the riot.render function in riot

To help you get started, we’ve selected a few riot 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 ListnPlay / riot-isomorphic / src / server / index.js View on Github external
async function render() {
        try {
            let view = riot.render(options.mainTag, options.tagOpts);
            let regex = new RegExp('<' + options.mainTag + '.*<\/' + options.mainTag + '>');
            // Loading HTML file
            let content = await Q.denodeify(FS.readFile)(filePath);
            let rendered = content.toString().replace(regex, view);
            return callback(null, rendered);
        }
        catch (e) {
            console.log("App engine error: ", e, " Filepath: ", filePath, " Callback: ", callback);
            console.log(e.stack);
            return;
        }
    }
github storynory / kisscms / helpers / fetchApi.js View on Github external
exports.sendRiot = function ( api, template, res ) {

  if ( api[ 0 ] === 'undefined' || api[ 0 ] == null ) {
    return res.status( 404 )
      .send( "not found" )
  } else {
    var riot = require( 'riot' ), // riot has to be called before postview
      postView = require( template ),
      Entities = require( 'html-entities' )
      .XmlEntities,
      entities = new Entities(),

      html = riot.render( postView, {
        posts: api[ 0 ]
      } );
    html = entities.decode( html )
    res.send( "" + html );

  }

};
github eden-js / cli / lib / utilities / engine.js View on Github external
// log render start
    let renderStart = options.routeEnd;

    // do try/catch
    try {
      // render page
      let page = '';
      page += '';
      page += '';
      page += '';
      page += '<title>' + (options.pagetitle ? options.pagetitle + ' | ' : '') + options.title + '</title>';
      page += '';
      page += options.head || '';
      page += '';
      page += '';
      page += riot.render (options.mount.layout, options);

      // delete server
      delete options.cdn;
      delete options.server;

      // set before
      let before = options.beforeScript || '';
      let after  = options.afterScript  || '';

      // delete post-render options
      delete options.beforeScript;
      delete options.afterScript;

      // do script section of page
      page += '
github prateekbh / riot-tagrouter / tests / isomorphism.js View on Github external
function createRouteWithTagName(tagName) {

		var tag = '&lt;' + tagName + ' class="route-' + tagName + '"&gt;';

		unmountCurrRoute();

		$appRoot.innerHTML = tag;
		var mountedTag;
		try {
			if (typeof window === 'undefined') {

				$appRoot.innerHTML = riot.render(tagName, routeParams);
			} else {
				mountedTag = riot.mount(tagName + '.route-' + tagName, routeParams);
			}
		} catch (e) {

			setTimeout(function () {
				throw e;
			}, 0);
		}
		if (!mountedTag || mountedTag.length === 0) {
			self.trigger('tagNotFound', tagName);
			if (self.opts['onTagnotfound'] &amp;&amp; self.opts['onTagnotfound'] instanceof Function) {
				self.opts['onTagnotfound'](tagName);
			}
		} else {
			self.trigger('routeChanged', tagName);
github prateekbh / riot-tagrouter / isomorphism / renderer.js View on Github external
var riot = require('riot');
var appRouteTag = require('./app-route.js');
console.log(riot.render('app-route', {location: '/user/profile/john'}));
github dwyl / hapi-riot / lib / index.js View on Github external
return function render (context, renderOpts) {
    var layoutFilePath, layoutFileName, content, View, compiledFileRoute;
    var mergedOpts = Object.assign({}, baseOpts, renderOpts);
    var riotTag = template.split('&gt;')[0].slice(1);

    loadTags(mergedOpts.filename);
    compiledFileRoute = mergedOpts.compiledFileRoute || '/bundle.js';
    View = require(mergedOpts.filename); //eslint-disable-line
    content = Riot.render(View, context)
    + '\n'
    + '\n'
    + '\n'
    ;
    if (mergedOpts.layout) {
      layoutFileName = mergedOpts.layout === true
        ? 'layout.html'
        : mergedOpts.layout
      ;
      layoutFilePath = Path.join(mergedOpts.layoutPath, layoutFileName);

      content = loadLayout(layoutFilePath).replace('&lt;&lt;&gt;&gt;', content);
    }

    /*
github dwyl / hapi-socketio-redis-riot-chat-example / lib / riot_handler.js View on Github external
getMessages(function (messagesFromRedis) {
    var messageStore = messagesFromRedis.map(JSON.parse);
    var renderedHTML = riot.render(message, {messageStore: messageStore});
    reply.view('index', {messages: renderedHTML } );
  });
}
github avanslaars / riot-server-render / app.js View on Github external
app.get('/',function(req,res){
  var startingName = 'Susan'
  var tagOutput = riot.render(hello,{firstName:startingName})
  res.render('index',{tagContent:tagOutput,firstName:startingName})
})
github pablosichert / universal-rendering / server / server.js View on Github external
app.use((req, res) => {
    var store = createStore(reducers, req.state);
    var html = riot.render(riotApp, {isClient: false, routes: routes, store: store, state: store.getState()});

    res.render('base', {
      html: html,
      state: req.state
    });
  });
github GianlucaGuarini / riot-app-example / server / app.js View on Github external
.then(function(data) {
        data.gateway = gateway
        data.user = new User()
        res.render('base', {
          initialData: JSON.stringify(data),
          body: render('app', data)
        })
      })
  })