仅在Haml中创建局部变量 [英] Create a local variable in Haml only
本文介绍了仅在Haml中创建局部变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Haml作为布局原型制作的快速方法.这不使用Rails,Sinatra或任何框架.
I'm using Haml as a quick way of prototyping layouts. This is not using Rails, Sinatra or any framework.
我想做的是在顶部声明一个变量,并能够在整个页面中调用它,类似于我可以在Sass中声明一个变量并在整个代码中使用它的方式.
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}"}
这可能吗?
推荐答案
拖放$
以避免声明全局变量.它应该可以正常工作.
Drop the $
to avoid declaring a global variable. It should work just fine.
!!! 5
%body
/ Declare Variable
- type = 'Audio'
.container{:id => "page-#{type}"}
这篇关于仅在Haml中创建局部变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文