gulp-riot-tsref

A gulp plugin for riot with TypeScript reference support.


Keywords
gulp, riot, gul-riot, typescript, d.ts
License
MIT
Install
npm install gulp-riot-tsref@1.0.0

Documentation

gulp-riot-tsref

A gulp plugin for riot with TypeScript reference support. This is a fork of the gulp-riot module (Much appreciate to jigsaw).

Circle CI npm version npm downloads npm license Dependency Status

Install

With npm do:

$ npm install --save-dev gulp-riot-tsref

Usage

This plugin compile riot's .tag files. This plugin also extract a script block from .tag files.

Example

Mode extract

example.tag:

<example>
  <p>This is { sample }</p>

  <script>
    /// <reference path="hoge.d.ts" />
    this.sample = new Hoge.Fuga().getMessage();
  </script>
</example>

gulpfile.js:

var gulp = require('gulp');
var riot = require('gulp-riot-tsref');

gulp.task('riot:extract', function() {
  return gulp.src('example.tag')
             .pipe(riot({"mode": "extract"}))
             .pipe(gulp.dest('dest'));
});

Run task:

% gulp riot:extract
% cat example.ts
/// <reference path="hoge.d.ts" />
this.sample = new Hoge.Fuga().getMessage();

Mode compile

example.tag:

<example>
  <p>This is { sample }</p>

  <script>
    /// <reference path="hoge.d.ts" />
    this.sample = new Hoge.Fuga().getMessage();
  </script>
</example>

hoge.d.ts

declare module Hoge {
    class Fuga {
        getMessage(): string;
    }
}

gulpfile.js:

var gulp = require('gulp');
var riot = require('gulp-riot-tsref');

gulp.task('riot:compile', function() {
  return gulp.src('example.tag')
             .pipe(riot())
             .pipe(gulp.dest('dest'));
});

Run task:

% gulp riot:compile
% cat example.js
riot.tag('example', '<p>This is { sample }</p>', function(opts) {
  this.sample = new Hoge.Fuga().getMessage();
})

Compile options

This plugin can give riot's compile options.

  gulp.src('example.tag')
      .pipe(riot({
        compact: true // <- this
      }))
      .pipe(gulp.dest('dest'));

Available option

Building

In order to build the gulp-riot-tsref, ensure that you have git and node.js installed.

Clone a copy of the repository:

$ git clone git@github.com:CODEYA/gulp-riot-tsref.git

Change to the gulp-riot-tsref directory:

$ cd gulp-riot-tsref

Install dev dependencies:

$ npm install

Build the gulp-riot-tsref:

$ npm run build

Test the gulp-riot-tsref:

$ npm test