显示标签为“Plugin”的博文。显示所有博文
显示标签为“Plugin”的博文。显示所有博文

2008年1月23日星期三

Tabnav

项目里用到了个plugin,叫Tabnav,具体见:http://www.seesaw.it/en/toolbox/widgets/

tab的name和link需要自己写个类来定义,以前的开发者将它放在models目录下(不知道可不可以放在别的目录下),命名为xyy_tabnav.rb
class XyyTabnav < Tabnav::Base
add_tab do
named 'tab_1'
links_to(lambda{ { :controller => 'xxx', :action => 'show', :id => 1 }})
end

add_tab do
named 'tab_2'
links_to(lambda{ { :controller => 'yyy', :action => 'index' }})
end
end
在Tabnav这个plugin的目录下,有个generators文件夹,里面相当于是个demo,模仿着用就行了。

Haml中的注释

以前一直不知道怎么在Haml中注释掉一段代码。
结果官方文档上写得清清楚楚:
/

The forward slash character, when placed at the beginning of a line, wraps all text after it in an HTML comment. For example:

%peanutbutterjelly
/ This is the peanutbutterjelly element
I like sandwiches!

is compiled to:

<peanutbutterjelly>
<!-- This is the peanutbutterjelly element -->
I like sandwiches!
</peanutbutterjelly>

The forward slash can also wrap indented sections of code. For example:

/
%p This doesn't render...
%div
%h1 Because it's commented out!

is compiled to:

<!--
<p>This doesn't render...</p>
<div>
<h1>Because it's commented out!</h1>
</div>
-->
还是跟缩进相关。

至于反斜杠\(backslash),当然是转义字符啦。
%title
= @title
\- MySite

is compiled to:

<title>
MyPage
- MySite
</title>

具体请参考官方文档:
The full Haml reference
The full Sass reference
The RDoc documentation