Haml Components
Last updated
Was this helpful?
Last updated
Was this helpful?
Another way to reuse your existing views and partials are components with *.haml templates. You can create a component and don't implement a response
method. In this case, Matestack will look for a *.haml file right next to it. In this *.haml file you can access all variables, methods, helpers and so on which you could access in a component. Let's take a closer look by recreating our product teaser component with a *.haml file. We create a file called teaser_haml.rb
in app/matestack/components/products/
.
Next we create the corresponding *.haml template. As said above, Matestack looks for this template next to the component file. So we will create it in app/matestack/components/products/teaser_haml.haml
.
After registering this component we can use it on Rails views with matestack_component
. This gives you the opportunity to reuse your views, part of them or partials easily by creating a component and moving your view markup into a *.haml file next to it. If you are not already using haml in your project checkout or many of the available online tools to convert your erb views effortless into *.haml views.