Permalink
Browse files

Merge pull request #37 from riot/v2

v2
  • Loading branch information...
2 parents 33ec6df + c96a53e commit 0738fd380d1ccae73f395706c96e2b7f986d27d1 @cognitom cognitom committed on GitHub Nov 25, 2016
Showing with 177 additions and 129 deletions.
  1. +20 −0 .eslintrc.json
  2. +1 −5 .travis.yml
  3. +7 −0 CHANGELOG.md
  4. +40 −28 README.md
  5. +16 −13 index.js
  6. +19 −9 package.json
  7. +74 −74 test/compile.js
View
@@ -0,0 +1,20 @@
+{
+ "env": {
+ "mocha": true,
+ "node": true
+ },
+ "extends": "eslint:recommended",
+ "parserOptions": {
+ "sourceType": "module"
+ },
+ "rules": {
+ "eqeqeq": ["error", "smart"],
+ "indent": ["error", 2],
+ "linebreak-style": ["error", "unix"],
+ "no-cond-assign": "off",
+ "no-console": "off",
+ "no-unexpected-multiline": "error",
+ "quotes": ["error", "single", "avoid-escape"],
+ "semi": ["error", "never"]
+ }
+}
View
@@ -1,9 +1,5 @@
----
language: node_js
node_js:
-- '0.10'
-script:
- - npm install
- - npm test
+ - '4.*'
notifications:
email: false
View
@@ -1,5 +1,12 @@
# CHANGELOG
+## 2.0.0
+
+ * Compatible with Riot 3.0.0
+ * Moved to Riot organization
+ * Make riot-compiler a peerDependency
+ * Add eslint
+
## 1.0.1
* Passing the file name to the riot compiler #30
View
@@ -1,13 +1,15 @@
[![Build
-Status](https://travis-ci.org/jhthorsen/riotify.svg)](https://travis-ci.org/jhthorsen/riotify)
+Status](https://travis-ci.org/riot/riotify.svg)](https://travis-ci.org/riot/riotify)
# riotify
"riotify" is a browserify transformer for [riot](https://muut.com/riotjs) ".tag" files.
## Installation
- npm install riotify
+```bash
+$ npm install riotify
+```
## Usage
@@ -17,34 +19,42 @@ This module is meant to be used together with
Either of the two commands below result creates the same result:
- browserify -t riotify app.js
- module-deps -t riotify app.js | browser-pack
+```bash
+$ browserify -t riotify app.js
+$ module-deps -t riotify app.js | browser-pack
+```
Example `app.js`:
- var riot = require('riot')
- var todo = require('./todo.tag')
- riot.mount(todo)
+```javascript
+var riot = require('riot')
+var todo = require('./todo.tag')
+riot.mount(todo)
+```
Example `todo.tag`:
- <todo>
- <div each={ items }>
- <h3>{ title }</h3>
- </div>
-
- // a tag file can contain any JavaScript, even require()
- var resources = require('../resources.json')
- this.items = [ { title: resources.en.first }, { title: resources.en.second } ]
- </todo>
+```html
+<todo>
+ <div each={ items }>
+ <h3>{ title }</h3>
+ </div>
+
+ // a tag file can contain any JavaScript, even require()
+ var resources = require('../resources.json')
+ this.items = [ { title: resources.en.first }, { title: resources.en.second } ]
+</todo>
+```
Note that your tag files actually need to have the extension ".tag".
### Compile Options
This plugin can give riot's compile options.
- % browserify -t [ riotify --type coffeescript --template jade ] app.js
+```bash
+$ browserify -t [ riotify --type coffeescript --template jade ] app.js
+```
You can also configure it in package.json
@@ -61,16 +71,16 @@ You can also configure it in package.json
#### Available option
-* compact: `Boolean`
- * Minify `</p> <p>` to `</p><p>`
-* expr: `Boolean`
- * Run expressions trough parser defined with `--type`
-* type: `String, coffeescript | cs | es6 | none`
- * JavaScript pre-processor
-* template: `String, jade`
- * HTML pre-processor
-* ext: `String`
- * custom extension, you’re free to use any file extension for your tags (instead of default .tag):
+- compact: `Boolean`
+ - Minify `</p> <p>` to `</p><p>`
+- expr: `Boolean`
+ - Run expressions trough parser defined with `--type`
+- type: `String, coffeescript | cs | es6 | none`
+ - JavaScript pre-processor
+- template: `String, jade`
+ - HTML pre-processor
+- ext: `String`
+ - custom extension, you’re free to use any file extension for your tags (instead of default .tag):
See more: https://muut.com/riotjs/compiler.html
@@ -95,7 +105,9 @@ These are the simplest cases. `uglify` and `sourcemaps` would be needed.
## Tests
- npm test
+```bash
+$ npm test
+```
## Author
View
@@ -1,23 +1,26 @@
-var through = require('through');
-var riot = require('riot');
-var preamble = "var riot = require('riot');\n";
+'use strict'
+
+const through = require('through')
+const compiler = require('riot-compiler')
+const preamble = "var riot = require('riot');\n"
module.exports = function (file, o) {
- var opts = o || {};
- var ext = opts.ext || 'tag';
- var content = '';
+ const opts = o || {}
+ const ext = opts.ext || 'tag'
+ let content = ''
- return !file.match('\.' + ext + '$') ? through() : through(
+ return !file.match(`\.${ ext }$`) ? through() : through(
function (chunk) { // write
- content += chunk.toString();
+ content += chunk.toString()
},
function () { // end
try {
- this.queue(preamble + 'module.exports = ' + riot.compile(content, opts, file));
- this.emit('end');
+ const compiled = compiler.compile(content, opts, file)
+ this.queue(`${ preamble }module.exports = ${ compiled }`)
+ this.emit('end')
} catch (e) {
- this.emit('error', e);
+ this.emit('error', e)
}
}
- );
-};
+ )
+}
View
@@ -1,23 +1,33 @@
{
"name": "riotify",
- "version": "1.0.1",
+ "version": "2.0.0",
"description": "browserify plugin for riot tag files",
"main": "index.js",
+ "files": [
+ "index.js"
+ ],
"dependencies": {
- "riot": "^2.3.0",
- "through": "^2.3.0"
+ "through": "^2.3.8"
},
"devDependencies": {
- "concat-stream": "^1.4.0",
- "module-deps": "^3.6.0",
- "tape": "^2.12.1"
+ "concat-stream": "^1.5.2",
+ "eslint": "^3.10.2",
+ "module-deps": "^4.0.8",
+ "tape": "^4.6.3",
+ "riot": "^3.0.0",
+ "riot-compiler": "^3.0.0"
+ },
+ "peerDependencies": {
+ "riot-compiler": "^3.0.0"
},
"scripts": {
- "test": "tape test/*.js"
+ "test": "npm run eslint && npm run tape",
+ "tape": "tape test/*.js",
+ "eslint": "eslint index.js test/*.js"
},
"repository": {
"type": "git",
- "url": "https://github.com/jhthorsen/riotify.git"
+ "url": "https://github.com/riot/riotify.git"
},
"keywords": [
"browserify",
@@ -27,6 +37,6 @@
"author": "Jan Henning Thorsen",
"license": "MIT",
"bugs": {
- "url": "https://github.com/jhthorsen/riotify/issues"
+ "url": "https://github.com/riot/riotify/issues"
}
}
Oops, something went wrong.

0 comments on commit 0738fd3

Please sign in to comment.