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

gulp-angular-htmlify

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-angular-htmlify

Change your ng-attributes to data-ng-attributes for html5 validation

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
272
decreased by-51.69%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-angular-htmlify

Change your ng-attributes to data-ng-attributes for HTML5 validation

NPM Version NPM Downloads Build Status

Ever tried to run an Angular HTML page into w3c validator? Yeah it's a mess.

The solution everyone recommends is to add data to all your ng directives. Now with gulp this can be easily made part of your build flow, similar to how ng-min is to creating minifiable Angular syntax.

Turn this:

<html ng-app="myApp">
...
<body ng-controller="MainCtrl">
</body>
</html>

Into this:

<html data-ng-app="myApp">
...
<body data-ng-controller="MainCtrl">
</body>
</html>
HTML5 Valid

gulp-angular-htmlify looks for ng- directives by default and can handle the following cases:

<!-- attribute -->
<ANY ng-directive>
<!-- regular element -->
<ng-directive></ng-directive>
<!-- self closing element -->
<ng-directive />
<!-- custom directive prefix -->
<ui-router></ui-router>
<!-- your name prefix -->
<gilad-cool-loader></gilad-cool-loader>

You can add additional prefixes using the option customPrefixes.

This plugin plays nice with type="text/ng-template" and won't break it.

Issues with the output should be reported on the angular-html5 issue tracker.

Install

Install with npm

npm install --save-dev gulp-angular-htmlify

Example

var gulp = require('gulp');
var htmlify = require('gulp-angular-htmlify');

//simple usage
gulp.task('htmlify', function() {
    gulp.src('public/**/*.html')
        .pipe(htmlify())
        .pipe(gulp.dest('build/'));
});

//using jade as a pre-processer
gulp.task('htmlify', function() {
    gulp.src('partials/**/*.jade')
        .pipe(jade())
        .pipe(htmlify())
        .pipe(gulp.dest('build/'));
});

//Also transforming ui-attributes to data-ui-attributes
gulp.task('htmlify', function() {
    gulp.src('public/**/*.html')
        .pipe(htmlify({
            customPrefixes: ['ui-']
        }))
        .pipe(gulp.dest('build/'));
});

API

htmlify(params)

params is an object that contains the following settings:

customPrefixes

Type: Array

Default: []

An array to optionally add custom prefixes to the list of converted directives.

For example: ['ui-', 'gijo-']

By default only ng- prefixes are are handled. Any items you add here will be handled as well.

Note: for this to work - you will need to make sure your directives can load with a data- prefix.

verbose

Type: Boolean

Default: false

Whether to log files that had ng-directives detected and replaced. (Useful for debugging).

Example usage:

//...
.pipe(htmlify({
    verbose:true,
    customPrefixes: ['ui-']
    }))
// --> [gulp] Found and replaced ng-directives in index.html
//...

License

MIT ©2014 Gilad Peleg

Keywords

FAQs

Package last updated on 05 Aug 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