I am trying to find a more DRY way to do the following:
- if request.xhr?
:javascript
{my javascript}
- else
= content_for :scripts do
:javascript
{my javascript}
I reuse this pattern in many haml files, so I am wondering what is the best way to abstract out the conditional logic. Ideally, I'd like to achieve something like the following in my haml files:
optional_content_for :scripts do
:javascript
{my javascript}
Thanks!