Rails has the content_for method which allows you to yield content into a layout later in the rendering phase of a view. Often I need the same functionality when using StaticMatic. Since I'm using Haml this is easier to do.
# page.haml
- @javascript = capture_haml do
alert("hello");
# layout.haml
:javascript
= @javascript