How can I use a local (or per view) variable in Sinatra with Haml partials?

Viewed 4004

I have a Haml partial in Sinatra to handle all of my 'page open' items like meta tags.

I would love to have a variable for page_title in this partial and then set that variable per view.

Something like this in the partial:

%title @page_title

Then in the view, be allowed to do something like:

@page_title = "This is the page title, BOOM!"

I have read a lot of questions/posts, etc. but I don't know how to ask for the solution to what I am trying to do. I'm coming from Rails where our devs usually used content_for but they set all that up. I'm really trying to learn how this works. It seems like I have to define it and use :locals in some way but I haven't figured it out. Thank you in advance for any tips!

1 Answers
Related