Coder Social home page Coder Social logo

riotify's Introduction

Build Status

riotify

"riotify" is a browserify transformer for riot ".tag" files.

Installation

npm install riotify

Usage

This module is meant to be used together with browserify or module-deps:

Either of the two commands below result creates the same result:

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)

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>

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

You can also configure it in package.json

{
    "name": "my-package",
    "browserify": {
        "transform": [
            [ "riotify", {"type": "coffeescript", "template": "jade" } ],
        ]
    }
}

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):

See more: https://muut.com/riotjs/compiler.html

With gulp.js

var gulp       = require('gulp');
var browserify = require('browserify');
var riotify    = require('riotify');
var source     = require('vinyl-source-stream');

gulp.task('browserify', function(){
  browserify({ entries: ['src/app.js'] })
  .transform(riotify, { template: 'jade' }) // pass options if you need
  .bundle()
  .pipe(source('app.js'))
  .pipe(gulp.dest('dist/'))
});

These are the simplest cases. uglify and sourcemaps would be needed.

Tests

npm test

Author

Jan Henning Thorsen - [email protected]

riotify's People

Contributors

cognitom avatar mathieulegrand avatar pajtai avatar samdoiron avatar speier avatar txchen avatar uzimith avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.