Boilerplate is not a framework, nor does it prescribe any philosophy of development, it's just got some tricks to get your project off the ground quickly and right-footed.
I like the idea of its build system to minify and gzip, but I'd probably only use it if I was working on a project that uses Ant. Since I'm using it in a Play project, the whole Ant build system doesn't help me. Besides, I prefer something like wro4j. Wro4j allows you to specify a group of files and then it compiles, minimizes and gzips them all on-the-fly. As far as I know, Play doesn't have any support for Servlet Filters, so using wro4j in Play is not trivial.
To add HTML5 Boilerplate to my Play project, I performed the following steps:
- Downloaded the 2.0 Zipball.
- Copied all the static files to my project. Below are the commands I used (where $boilerplate-download is the expanded download directory and ~/dev/play-more is my project):
- Copied the index.html to ~/dev/play-more/app/templates/layouts/default.jade and modified it to use Jade syntax. Since I downloaded the comments-heavy version, I modified many of them to be hidden in the final output.
- Next, I had to add support for layouts to my homegrown Scalate support. I did this by specifying a
layoutStrategywhen initializing the TemplateEngine. From play-more/app/controllers/ScalateTemplate.scala:
engine.classLoader = Play.classloader engine.layoutStrategy = new DefaultLayoutStrategy(engine, Play.getFile("/app/templates/layouts/default" + scalateType).getAbsolutePath) engine
That's it! Now I have HTML5 Boilerplate integrated into my Play/Scalate/Jade application. To set the title and header in my index.jade, I simply added the following lines at the top:
- attributes("title") = "Counting" - attributes("header") = "HTML5 Rocks!"
Then I was able to write CoffeeScript in a .jade template using the following syntax:
:plain <script type="text/coffeescript"> alert "hello world" </script>
If you've integrated HTML5 Boilerplate into your Play application, I'd love to hear about it. Now that I have all the infrastructure in place (Jade, CoffeeScript, HTML5 Boilerplate), I'm looking forward to getting some development done. Who knows, maybe I'll even come up with my own Play Un-Features That Really Irk My Inner Geek.