…the Ruby way. We have a ton of templates for the Web-Empowered Church Starter Package, so you can imagine the work of having to make a change to it that goes beyond simple updates. We decided to replace chc_forum with mm_forum because it’s newer and better maintained, which meant to update all those templates with new styles for the new forum. Not only that, but each added style needs to match the template, so color schemes have to be different depending on the current template.
Us programmers are very lazy, so I decided to write a script that does all that for us instead of wasting hours and hours on brainless work. It’s available on the WEC SVN server. In a nutshell, there are two file to edit: template.css, and config.yaml.
The template.css file contains the new content that will be appended to the existing styles files. It contains placeholders %1-%3 that will be dynamically filled in with the right colors for this template.
The config.yaml file contains the meat of the application. Check out the inline comments for more details, but you basically give it a regular expression to apply to the existing template styles and tell it which capturing group to use as a substitute. You can give as many regular expressions/arguments as you want, but the number has to match the number of markers in the template file. The second part of the yaml config is a list of paths and files that tell the script which file to append and parse for the substitute styles.
It was fun writing and can be used to append pretty much anything to any file you want, so it may be helpful to you!
Related posts:

Dude, you are so smart. Thanks for all your help all the time when I’m too dumb to figure out the BSU site!
You’re welcome
Hope everything’s going well! Added your blog to my blogroll!