使用Rails制作水平的导航菜单
Memu帮助类:
#encoding: utf-8
module MenuHelper
def topmenu
pages = {
"pages" => { :name => '首页', :link => root_path},
"recent" => { :name => '最新', :link => recent_path },
"hot" => { :name => '热门', :link => hot_path },
"class" => { :name => '分类', :link => class_path }
}
pages.map do |key, value|
classnames = ' class=current-menu-item' if controller.controller_name == key
"<li#{classnames}>#{link_to(value[:name], value[:link])}</li>"
end
end
endView前端脚本 来至 lehazi.com Q群193737895
<ul>
<%= raw topmenu.join %>
</ul> 相关推荐
EricNet 2020-07-05
EricNet 2020-05-27
何志文 2020-05-11
JOO 2020-04-26
happyfreeangel 2020-04-09
Poisedflw 2020-03-23
yangliuhbhd 2020-03-06
Ben的程序员生涯 2013-06-01
chenshuixian 2013-06-01
wes0 2014-05-31
mrice00 2019-12-20
EricNet 2019-12-11
89304896 2019-12-08
lihaoningxia 2013-07-09
userguanguan 2015-03-16