NAME
Mojolicious::Plugin::Riotjs - A Mojolicious plugin for including riot.js .tag files in your project
VERSION
0.02
DESCRIPTION
Mojolicious::Plugin::Riotjs is a Mojolicious plugin for including riot.js .tag
files in your project. It also makes it very easy to bundle the latest riot.js.
What is riotjs?
From the web page:
A REACT-LIKE, 2.5KB USER INTERFACE LIBRARY
Custom tags - Virtual DOM - Full stack - IE8
Dependencies
Riot is required for this module to work. You can install Riot with npm:
$ sudo apt-get install npm
$ npm install riot
SYNOPSIS
use Mojolicious::Lite;
get "/" => "index";
app->plugin("riotjs");
app->asset(
"app.js" => qw(
https://muut.com/riotjs/dist/demo/js/riot.js
/js/todo.tag
/js/main.js
)
);
app->start;
__DATA__
@@ /js/todo.tag
<todo>
<h3>{ opts.title }</h3>
<ul>
<li each={ item, i in items }>{ item.title }</li>
</ul>
<form onsubmit={ add }>
<input>
<button>Add #{ items.length + 1 }</button>
</form>
this.items = []
add(e) {
var input = e.target[0]
if (input.value.length) this.items.push({ title: input.value })
input.value = ''
}
</todo>
@@ /js/main.js
riot.mount('todo')
@@ index.html.ep
<!DOCTYPE html>
<html>
<head>
<title>Riot.js Demo</title>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.5/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script>html5.addElements('todo')</script>
<![endif]-->
</head>
<body>
<todo></todo>
%= asset "app.js"
</body>
</html>
METHODS
node_paths
@paths = $self->node_paths($app);
Returns the path to available "node_modules". This is used by "register" to set the NODE_PATH
environment variable.
The default is to look for "node_modules" in current directy and relative to project home. It will also use the current value of NODE_PATH
if already set.
register
Will register the Mojolicious::Plugin::Riotjs::Preprocessor with the ".tag" file extension.
COPYRIGHT AND LICENSE
Copyright (C) 2014, Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org