diff --git a/index.js b/index.js index 6e918a4..626a01f 100644 --- a/index.js +++ b/index.js @@ -6,33 +6,9 @@ module.exports = function (params) { //perhaps in the future params = params || {}; var verbose = params.verbose || false; - var customPrefixes = params.customPrefixes || []; - - //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}'; - - //handle the following: - //1. ' ng-' - //2. ' allowable pre-chars - //$2 -> prefix match - //$3 -> actual directive (partially) - var replaceRegex = new RegExp(allowedPreChars + prefix + '(\\w+)', 'ig'); - - //replace with data-ng-something - var replaceStr = '$1data-$2$3'; + var htmlify = require('angular-html5')({ + customPrefixes: params.customPrefixes + }); return through.obj(function (file, enc, cb) { //pass through @@ -49,8 +25,8 @@ module.exports = function (params) { var data = file.contents.toString('utf8'); //if ng-directives exist - if (replaceRegex.test(data)) { - data = data.replace(replaceRegex, replaceStr); + if (htmlify.test(data)) { + data = htmlify.replace(data); //put contents back file.contents = new Buffer(data); if (verbose) { diff --git a/license.md b/license.md index 7493179..5f9e1a7 100644 --- a/license.md +++ b/license.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) [2014] [Gilad Peleg] +Copyright (©) 2014 Gilad Peleg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/package.json b/package.json index 6cc92d2..eaf7210 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,12 @@ }, "license": "MIT", "devDependencies": { - "mocha": "^1.20.0" + "gulp-util": "^2.2.16", + "mocha": "^1.20.1" }, "dependencies": { + "angular-html5": "^0.1.1", "gulp-util": "^2.2.14", - "through2": "^0.4.2" + "through2": "^0.5.1" } } diff --git a/readme.md b/readme.md index c43d86e..adaad92 100644 --- a/readme.md +++ b/readme.md @@ -50,6 +50,8 @@ 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 ng-annotate [issue tracker](https://github.com/pgilad/angular-html5/issues).* + ## Install Install with [npm](https://npmjs.org/package/gulp-angular-htmlify)