Skip to content

Instantly share code, notes, and snippets.

@dmiddle2000lb
Created October 10, 2014 12:43
Show Gist options
  • Save dmiddle2000lb/96857c40ac1ef4cc01ba to your computer and use it in GitHub Desktop.
Save dmiddle2000lb/96857c40ac1ef4cc01ba to your computer and use it in GitHub Desktop.
retire feature flag directive
// 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);
}
});
}
}
}
}
});
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