gulp-html-to-ts

0.1.3 • Public • Published

HTML template to TS

This gulp plugin converts a html file with into a ts file containing an object with string template.

Writing template inside a structured HTML file is much more practical than in a one line javascript string. Therefore this plugin turns a HTML file with templates into a js object. You can use whatever template language you like it simply turns the html nodes into a js string. It will take the html name file to named module and property html as string value.

Usage

An example usage with gulp:

var gulp        = require('gulp');
var html2ts = require('gulp-html2ts');
 
gulp.task('template', function() {
    return gulp.src( 'my/template.html' )
    .pipe( html2ts() )
    .pipe( gulp.dest( './' ) ); //generate my/template.html.ts
});
 

Example

This example shows how this plugin turn html into a ts file.

HTML Source : mytemplate.html

  <p>A {{ handlebar }} example.</p>

The generated output : mytemplate.html.ts

module mytemplate { export var html = '<p>A {{ handlebar }} example.</p>';}

Package Sidebar

Install

npm i gulp-html-to-ts

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • abraaoalves