Having used Haml and Sass for a few Rails side projects, I’ve found that they speed up my frontend development tremendously. However, I haven’t found a Rails blogging platform that’s as robust or familiar to clients as WordPress, so that’s still generally my go-to for projects that require a light website with basic CMS / blogging functionality. (I’ve looked into Radiant, Mephisto, etc, and while I certainly appreciate suggestions of Rails blog engines, that’s not really the question I’m looking to answer here.)
I’d really like to be able to use Haml and Sass in the context of a WordPress site, and while I’m aware of the existence of various PHP implementations, most seem inactive or buggy. Has anyone here had success using Haml and Sass with WordPress sites? I’m asking this both in the context of WordPress template files (the .php files that power a WordPress theme) and in the HTML editing mode of the WordPress editor, though the latter is far less important.
Note: I’m aware that I can just install the appropriate ruby gems and compile my own HTML/CSS from the Haml/Sass source; what I’m looking for is something more along the lines of the functionality I’m used to in Rails, where the compiled HTML/CSS is autogenerated on a per-request basis (caching behaviour would also be nice, but is certainly not required).
Thanks in advance!
You probably want to check out WORDLESS
https://github.com/welaika/wordless
It’s a WordPress plug-in that comes with compass/SASS, CoffeScript, and Haml.
I’m in the same boat with respect to the sites with a low demand for customization. I’m so used to Haml and Sass that going back to HTML and CSS seems painful. PHamlP has gotten some good reviews, especially because it supports Sass: (http://code.google.com/p/phamlp/). Still, there’s no substitute for the real thing.
If it were my project, I’d consider Compass and just do a compass update when I made changes. Sass is too good to pass up. Haml is your daily bread and butter, but Sass can really help you make pages sing. It suggests stylesheet refactorings you might never have thought of otherwise.
Here is a new plugin I just released: http://wordpress.org/extend/plugins/wordpress-sass/
It does use PHamlP, with all its warts, but at least it doesn’t require Compass on the server.
The plugin is very simple to implement and automatically regenerates your style.css whenever the style.scss file (or whatever you choose to name it) is updated.
More info: http://blogrescue.com/2011/12/sass-for-wordpress/
Ed
I created a development toolkit to make using HAML, PHP, and SASS a breeze with WordPress themes. It also compiles your JavaScript! Everything ends up compiled together into a WordPress theme. When I came across this question, this was my solution. I hope this helps a bit:
https://github.com/zachfeldman/wordpress-haml-sass
Haml requires Ruby at runtime. So you will not be able to use that for WordPress templates. Thus, you have to rely on a PHP implementation.
For Sass, you can use the console tool Sass –watch for auto-compilation. See this blog post. Additionally, there is the Compass App, which gives you all the Compass features in a convenient OSX app.
For HAML there is http://haml-to-php.com now. phamlp is too broken. Without rewrtiing it from scratch you can’t make it work. See github.com/MarcWeber/phamlp. Eventually a decent SASS implementation will be created as well.
If you don’t afraid of edge, you can try this plugin for WordPress: https://github.com/sxua/HAML-SASS-for-Wordpress.
More details soon at Github.
Not as cool as running it on the server on a per-request basis, but FWIW, I built a script to auto-compile my haml/sass on my dev machine so at least I can use haml/sass to easily generate my WordPress templates and CSS: https://gist.github.com/1169586 Enjoy!
I realise this is an older thread, but I landed here so others might too. There are a number of gulp and grunt plugins that will do this, however if you’re on OSX, CodeKit is super convenient.
And the folks over on this SO thread, offer suggestions on how to compile haml in php files.