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