Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@benmj
Forked from dmiddle2000lb/gist:96857c40ac1ef4cc01ba
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmj/35886b7a898be2af7f1f to your computer and use it in GitHub Desktop.
Save benmj/35886b7a898be2af7f1f to your computer and use it in GitHub Desktop.
// 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