gulp-angular-htmlify
Advanced tools
Comparing version 0.0.4 to 0.0.5
23
index.js
@@ -9,7 +9,24 @@ 'use strict'; | ||
var verbose = params.verbose || false; | ||
var customPrefixes = params.customPrefixes || []; | ||
//find ng-something | ||
var replaceRegex = /([\s<\/]+)ng-(\w+)/ig; | ||
//find ng-something by default | ||
var prefix = 'ng-'; | ||
//optionally add custom prefixes | ||
if (customPrefixes && customPrefixes.length) { | ||
var additions = customPrefixes.join('|'); | ||
prefix += '|'; | ||
prefix += additions; | ||
} | ||
//wrap around to insert into replace str later | ||
prefix = '(' + prefix + '){1}'; | ||
//build find/replace regex | ||
//$1 -> allowable pre-chars | ||
//$2 -> prefix match | ||
//$3 -> actual directive (partially) | ||
var replaceRegex = new RegExp('([\\s<\/]+)' + prefix + '(\\w+)', 'ig'); | ||
//replace with data-ng-something | ||
var replaceStr = '$1data-ng-$2'; | ||
var replaceStr = '$1data-$2$3'; | ||
@@ -16,0 +33,0 @@ return through.obj(function (file, enc, cb) { |
{ | ||
"name": "gulp-angular-htmlify", | ||
"description": "Change your ng-attributes to data-ng-attributes for html5 validation", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=0.10.0" |
@@ -43,2 +43,6 @@ # [gulp](https://github.com/wearefractal/gulp)-angular-htmlify | ||
<ng-directive /> | ||
<!-- custom directive prefix --> | ||
<ui-router></ui-router> | ||
<!-- your name prefix --> | ||
<gilad-cool-loader></gilad-cool-loader> | ||
``` | ||
@@ -73,2 +77,14 @@ | ||
#### customPrefixes | ||
Type: `Array` | ||
An array to optionally add custom prefixes to the list of converted directives. | ||
For example: `['ui-', 'gijo-']` | ||
*Note: for this to work - you will need to make sure your directives **can** load with a `data-` prefix.* | ||
Defaults to **[]** | ||
#### verbose | ||
@@ -86,3 +102,4 @@ | ||
.pipe(htmlify({ | ||
verbose:true | ||
verbose:true, | ||
customPrefixes: ['ui-'] | ||
})) | ||
@@ -89,0 +106,0 @@ // --> [gulp] Found and replaced ng-directives in index.html |
5536
54
110