Forked from dmiddle2000lb/gist:96857c40ac1ef4cc01ba
Last active
August 29, 2015 14:07
-
-
Save benmj/35886b7a898be2af7f1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given the markup: <a href="#hashtag" feature-flag="phaseTwo" class="whatevs-yo">don't click</a> | |
// and the task to "retire" feature flag settings from the markup (ie B-03572) | |
// grunt feature --retire=phaseTwo | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
dom_munger: { | |
feature_flags: { | |
src: ['path/to/views'], | |
options: { | |
callback: function($, file) { | |
var flag = 'feature-flag'; | |
$('[' + flag + ']').filter(function() { | |
if ($(this).attr(flag) === grunt.option('retire')) { | |
$(this).removeAttr(flag); | |
} else if ($(this).attr(flag) === '!'.concat(grunt.option('retire')) { | |
$(this).remove(); | |
} | |
}); | |
} | |
} | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-dom-munger'); | |
grunt.registerTask('feature', ['dom_munger:feature_flags']); | |
}; | |
// expected output: <a href="#hashtag" class="whatevs-yo">don't click</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment