Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-ng-html2js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-ng-html2js

A Gulp plugin which generates Javascript code which loads the HTML files of your AngularJS app into the $templateCache.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5K
increased by1.93%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-ng-html2js NPM version Build Status Dependency Status

A plugin for gulp which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doens't need to request the actual HTML files anymore.

Usage

First, install gulp-ng-html2js as a development dependency:

npm install --save-dev gulp-ng-html2js

Then, add it to your gulpfile.js:

var ngHtml2Js = require("gulp-ng-html2js");

gulp.src("./partials/*.html")
	.pipe(ngHtml2Js({
		moduleName: "MyAwesomePartials",
		prefix: "/partials"
	}))
	.pipe(gulp.dest("./dist/partials"));

The main reason to use this module would be optimization. By pre-loading the HTML files, you can spare requests and loading time when the files are actually needed. When you are optimizing, you should do it properly. So, we should add the following plugins: gulp-minify-html, gulp-uglify, and gulp-concat:

var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");

gulp.src("./partials/*.html")
	.pipe(minifyHtml())
	.pipe(ngHtml2Js({
		moduleName: "MyAwesomePartials",
		prefix: "/partials"
	}))
	.pipe(concat("partials.min.js"))
	.pipe(uglify())
	.pipe(gulp.dest("./dist/partials"));

This way you end up with 1 single, minified Javascript file, which pre-loads all the (minified) HTML templates.

API

ngHtml2Js(options)

options.moduleName

Type: String

The name of the generated AngularJS module. Uses the file url if omitted.

options.prefix

Type: String

The prefix which should be prepended to the file path to generate the file url.

options.stripPrefix

Type: String

The prefix which should be subtracted from the file path to generate the file url.

License

MIT License

Keywords

FAQs

Package last updated on 04 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc