All Projects → TehShrike → riot-state-renderer

TehShrike / riot-state-renderer

Licence: other
a RiotJS-based renderer for the abstract-state-router

Programming Languages

javascript
184084 projects - #8 most used programming language

Use Riot with abstract-state-router!

Warning: Muut has on several occasions broken backwards compatibility in the Riot API without bumping major or even minor version numbers. If you get weird errors, make sure you're on at least 2.0.15. If you are getting errors on a version greater than 2.0.15 please open an issue or pull request.

Install

npm + your favorite CommonJS bundler is easiest.

npm install riot-state-renderer

You can also download the stand-alone build from wzrd.in. If you include it in a <script> tag, a riotStateRenderer function will be available on the global scope.

Usage

var StateRouter = require('abstract-state-router')
var riotRenderer = require('riot-state-renderer')()
var domready = require('domready')

var stateRouter = StateRouter(riotRenderer, 'body')

// add whatever states to the state router

domready(function() {
	stateRouter.evaluateCurrentRoute('login')
})

riotRenderer([options])

options is an object that is passed into riot.mount as the default opts object.

var StateRouter = require('abstract-state-router')
var riotRenderer = require('riot-state-renderer')

var renderer = riotRenderer({
	hello: 'world'
})

var stateRouter = StateRouter(renderer, 'body')

Working with states

All templates must be created as custom tags manually (or automatically with something like riotify).

When you add a state to the state router, pass in the tag name as the "template".

For details on setting up states themselves, see the abstract-state-router.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].