mirror of
https://github.com/HackPlan/gulp-angular-cloak.git
synced 2026-01-12 17:02:35 +08:00
better handling for element tags
This commit is contained in:
@@ -10,8 +10,11 @@
|
||||
<body ng-controller="MainCtrl">
|
||||
<div ng-class="{active:somethingForNothing()}">
|
||||
<span ng-if="rainbows()"></span>
|
||||
|
||||
</div>
|
||||
<ng-include="index.html"></ng-include>
|
||||
<ng-pluralize count="personCount" when="{'0': 'Nobody is viewing.',
|
||||
'one': '1 person is viewing.',
|
||||
'other': '{} people are viewing.'}" />
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
2
index.js
2
index.js
@@ -8,7 +8,7 @@ module.exports = function (params) {
|
||||
var verbose = params.verbose || false;
|
||||
|
||||
//find ng-something
|
||||
var replaceRegex = /(\s+)ng-(\w+)/ig;
|
||||
var replaceRegex = /([\s<\/]+)ng-(\w+)/ig;
|
||||
//replace with data-ng-something
|
||||
var replaceStr = '$1data-ng-$2';
|
||||
|
||||
|
||||
77
package.json
77
package.json
@@ -1,40 +1,41 @@
|
||||
{
|
||||
"name": "gulp-angular-htmlify",
|
||||
"description": "Change your ng-attributes to data-ng-attributes for html5 validation",
|
||||
"version": "0.0.3",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pgilad/gulp-angular-htmlify"
|
||||
},
|
||||
"homepage": "https://github.com/pgilad/gulp-angular-htmlify",
|
||||
"bugs": "https://github.com/pgilad/gulp-angular-htmlify/issues",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"gulp",
|
||||
"angular",
|
||||
"w3c",
|
||||
"validator",
|
||||
"html5",
|
||||
"data-ng",
|
||||
"ng"
|
||||
],
|
||||
"author": {
|
||||
"name": "Gilad Peleg",
|
||||
"email": "giladp007@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp-util": "^2.2.14",
|
||||
"through2": "^0.4.1"
|
||||
}
|
||||
"name": "gulp-angular-htmlify",
|
||||
"description": "Change your ng-attributes to data-ng-attributes for html5 validation",
|
||||
"version": "0.0.3",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pgilad/gulp-angular-htmlify"
|
||||
},
|
||||
"homepage": "https://github.com/pgilad/gulp-angular-htmlify",
|
||||
"bugs": "https://github.com/pgilad/gulp-angular-htmlify/issues",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"watchTest": "mocha --watch",
|
||||
"test": "mocha"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"gulp",
|
||||
"angular",
|
||||
"w3c",
|
||||
"validator",
|
||||
"html5",
|
||||
"data-ng",
|
||||
"ng"
|
||||
],
|
||||
"author": {
|
||||
"name": "Gilad Peleg",
|
||||
"email": "giladp007@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp-util": "^2.2.14",
|
||||
"through2": "^0.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
10
readme.md
10
readme.md
@@ -32,6 +32,16 @@ ng-min is to creating minfiable Angular syntax.
|
||||
```
|
||||
#### <img src="http://www.w3.org/html/logo/downloads/HTML5_Logo_256.png" alt="HTML5 Valid" width="64" height="64"/>
|
||||
|
||||
**gulp-angular-htmlify** currently handles the following cases:
|
||||
```html
|
||||
<!-- attribute -->
|
||||
<ANY ng-directive>
|
||||
<!-- regular element -->
|
||||
<ng-directive></ng-directive>
|
||||
<!-- self closing element -->
|
||||
<ng-directive />
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://npmjs.org/package/gulp-angular-htmlify)
|
||||
|
||||
6
test.js
6
test.js
@@ -67,6 +67,12 @@ it('should handle a complex angular app', function (cb) {
|
||||
assert(/\s+data-ng-if/.test(contents));
|
||||
//test that ng-if doesn't appear
|
||||
assert(!/\s+ng-if/.test(contents));
|
||||
//handle a <ng-include> directive
|
||||
assert(/<data-ng-include/.test(contents));
|
||||
//test that ng-if doesn't appear
|
||||
assert(!/<ng-include/.test(contents));
|
||||
//handle a <ng-include> directive
|
||||
assert(/<data-ng-pluralize/.test(contents));
|
||||
});
|
||||
|
||||
stream.on('end', cb);
|
||||
|
||||
Reference in New Issue
Block a user