Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-riot

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-riot

Render Riot.js Components with Vision in your Hapi.js Web Applications!

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

hapi-riot

Helps you Render Riot Components Server-side in your Hapi.js Web Application.

Build Status codecov Code Climate dependencies Status devDependencies Status

Why?

We really like the simplicity of Riot.js.
If you want to know why we think Riot.js is (much) "better" than other "View Libraries" or "Frameworks", please see:

What?

Server-side rendering of Riot Components using the Vision Plugin.

How?

Install

npm install hapi vision hapi-riot --save

Use it

server.register(Vision, (err) => {

  if (err) {
    console.log('Failed to load vision.');
  }

  server.views({ // initialise
    engines: {
      tag: require('hapi-riot') // file should be .tag
    },
    relativeTo: __dirname, // assuming your
    path: 'views' // by convention we put our tags in /views dir
  });

  server.route({ // define the route
    method: 'GET',
    path: '/',
    handler: (request, reply) => { // render the view:
      reply.view('index', { title: 'My Amazing Title!');
    }
  });
}

More/Complete examples are in the /examples directory.
If you need more, just ask! https://github.com/dwyl/hapi-riot/issues

Optional compileOptions (That Simplify Your Life!)

We have added a few features to simplify our own projects.
These are documented below, but are not meant to be fit for everyone. None are enabled by default so if you "just" want to render simple Riot Components as your Hapi Views, follow the simple example.

Doctype (default)

Riot does not like it when you include "unbalanced" tags. So, instead of manually including the DOCTYPE declaration at the top of your tag it gets "injected" at the top of the rendered view by hapi-riot.

removeCache

While you are developing your app you typically don't want your views to be cached, however, when you deploy your app by setting NODE_ENV=production views will be cached.

If for any reason you want to cache your views during development, or if you need to debug production on your localhost, set the compileOptions.removeCache: false like this:

server.views({ // initialise
  engines: {
    tag: require('hapi-riot') // file should be .tag
  },
  relativeTo: __dirname, // assuming your
  path: 'views', // by convention we put our tags in /views dir
  compileOptions: {
    removeCache: false
  }
});

FAQs

Package last updated on 04 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc