I have a web project that I am ripping out all the inline styling and adding it to a CSS file, and I can’t help but think there is an easier way to do this.
My current process is:
- Search Solution for
style=", if none selected, goto:9 - Cut all the text between the quote marks
- Create new class in CSS file
- Paste code in class
- Copy class name
- Return to html line and paste class name in between quote marks
- Rename
styletoclass - goto:
1 - Rejoice!
I would really like to rejoice, but there seems to be a never ending supply of inline styling.
Is there a way to automate this process in Visual Studio 2010? If it requires writing a plugin, that is totally fine! I have this same task to do on many a project.
Also, I’d like to be able to do this for arbitrary tags. For example, I’m also taking all of the data-* tags and doing roughly the same thing, but adding a line of jQuery to add it back in. Something like:
$('SELECTOR').attr('data-bind','visible: IsValid');
The work is too repetitious for me not to believe there is an automated (or at least faster/better/less time consuming) way of doing this.
The project is an MVC project if that changes anything.
If you’re looking for tool to replace inline style to css class, there are tools available:
http://www.voodoobytes.info/humbles-tools/
http://www.tinytool.net/96002/inline_css_extractor