cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

Additional Options #18

Open ProLoser opened 10 years ago

ProLoser commented 10 years ago

This is more a RFC cuz I'm not 100% sure this is necessary.

What do you think about adding a replace, after and before options?

The reason is because we had to replace a LESS import to a CSS import and rather than doing 3 separate updates it was easier to just replace. You can't append/prepend however since a <link> doesn't have children.

Also, theoretically if you have after or before you don't need replace since you can just remove the original element afterwards.

cgross commented 10 years ago

Yea I think all of those would be good additions. Correctly placing a new element inside the HTML is a little hairy with a DOM-based solution since you don't get to use comment markers like you would if you're just doing string parsing/replacement. before and after would alleviate that somewhat. replace also seems to have a very generic applicability.