Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a local variable in Haml only

Tags:

haml

I'm using Haml as a quick way of prototyping layouts. This is not using Rails, Sinatra or any framework.

What I want to do is declare a variable at the top and be able to call it throughout the page, similar to the way I can declare a variable in Sass and use it throughout the code.

!!! 5
  %body
    / Declare Variable
    - $type = 'Audio'

    .container{:id => "page-#{$type}"}

Is this possible?

like image 755
Adam Avatar asked Sep 14 '12 19:09

Adam


1 Answers

Drop the $ to avoid declaring a global variable. It should work just fine.

!!! 5
  %body
    / Declare Variable
    - type = 'Audio'
    .container{:id => "page-#{type}"}
like image 156
Kyle Avatar answered Nov 02 '22 07:11

Kyle