ght

gulp-html-to-ts

A gulp plugin that converts a html file into a ts file containing an object with html as string template.

Showing:

Popularity

Downloads/wk

3

GitHub Stars

2

Maintenance

Last Commit

6yrs ago

Contributors

2

Package

Dependencies

2

Size (min+gzip)

25.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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-html-to-ts');

gulp.task('template', function() {
    return gulp.src('my/template.html')
    .pipe(html2ts())
  //.pipe(html2ts('app'))
  //.pipe(html2ts({ moduleName: '{$folderName}', propertyName: '{$fileName}Html'}))
    .pipe(gulp.dest('./')); 
});

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>';}

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100