Developer Blog

  • Blog
  • /
  • Dynamic Partials in Haml templates
By Dracony on 28 March 2013

It is now possible to pass variables, or any kinda of expression for that matter, to partials. E.g you can now do this:

1
2
- $subview='pixielist'
partial:$subview

Of course you can pass the subview variable from the controller, there is nothing special about it. If you have been using the haml module there is one small change you have to make before updating to this version: since partials are now treated as expressions you have to put template names into quotes, e.g.:

1
2
3
4
5
//Old way
partial:fairy

//New way
partial:'fairy'
comments powered by Disqus