Permalink
Browse files

Use API from evil-icons package

  • Loading branch information...
1 parent 3574634 commit 502f4379a3d647b0c3d67e5eb75a755146dc5491 @outpunk outpunk committed Jan 17, 2015
Showing with 4 additions and 50 deletions.
  1. +1 −45 index.js
  2. +3 −5 package.json
View
@@ -14,57 +14,13 @@ var icons = require("evil-icons");
var PluginError = gutil.PluginError;
-function buildParamsFromString(string) {
- var paramsString;
- var params = {};
- var string = string.trim().replace(/['"]/gi, '');
-
- string.split(' ').forEach(function(param){
- var param = param.split('=');
- var key = param[0];
- var value = param[1];
-
- params[key] = value;
- });
-
- return params;
-}
-
-
-function replaceIconTags(src) {
- var match, tag, params, icon, name;
- var html = src.toString();
- var iconRegexp = /<icon\s+([-=\w\d'"\s]+)\s*\/?>(<\/icon>)?/gi;
-
- while (match = iconRegexp.exec(html)) {
- tag = match[0];
- params = buildParamsFromString(match[1]);
- name = params.name;
-
- delete params.name;
-
- icon = icons.icon(name, params)
- html = html.replace(tag, icon);
- }
-
- return html;
-}
-
-
-function iconize(src) {
- var html = src.toString();
- html = html.replace(/<body.*?>/, function(match) { return match + icons.sprite });
- return replaceIconTags(html);
-}
-
-
function gulpEvilIcons() {
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
cb(null, file);
}
- var html = iconize(file.contents);
+ var html = icons.iconizeHtml(file.contents);
if (file.isBuffer()) {
file.contents = new Buffer(html);
View
@@ -1,6 +1,6 @@
{
"name": "gulp-evil-icons",
- "version": "0.1.4",
+ "version": "0.1.5",
"description": "Gulp plugin to use Evil Icons in your project",
"main": "index.js",
"scripts": {
@@ -23,9 +23,7 @@
"homepage": "https://github.com/outpunk/gulp-evil-icons",
"dependencies": {
"gulp-util": "^3.0.1",
- "through2": "^0.6.3"
- },
- "peerDependencies": {
- "evil-icons": "^1.4.0"
+ "through2": "^0.6.3",
+ "evil-icons": "^1.5.0"
}
}

0 comments on commit 502f437

Please sign in to comment.