Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Menjoy/gulp-html2string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

20 Commits

Repository files navigation

gulp-html2string

Build Status

A Gulp plugin that converts static HTML templates to JavaScript strings.

Code derived from gulp-html2js.

Installation

npm install gulp-html2string

Usage

In your project's gulpfile.js, create the following task:

var html2string = require('gulp-html2string');
gulp.task('html2js', function () {
 return gulp.src('html/*.html')
 .pipe(html2string({
 base: path.join(__dirname, 'html'), //The base path of HTML templates
 createObj: true, // Indicate wether to define the global object that stores
 // the global template strings
 objName: 'TEMPLATES' // Name of the global template store variable
 //say the converted string for myTemplate.html will be saved to TEMPLATE['myTemplate.html']
 }))
 .pipe(rename({extname: '.js'}))
 .pipe(gulp.dest('templates/')); //Output folder
 });

Then run

gulp html2js

and your converted JS files will be saved under ./templates/.

Tests

Run

npm run test

See /test/test.js for an example usage.

About

Converts static HTML templates to JavaScript strings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.2%
  • HTML 1.8%

AltStyle によって変換されたページ (->オリジナル) /