better handling for element tags

This commit is contained in:
Gilad Peleg
2014-04-05 12:16:22 +03:00
parent a8011ec5e3
commit d5c3ab03e7
5 changed files with 60 additions and 40 deletions

View File

@@ -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>

View File

@@ -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';

View File

@@ -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"
}
}

View File

@@ -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)

View File

@@ -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);