逃避Ruby url helper中的斜杠

时间:2010-08-08 22:09:21

标签: ruby uri haml staticmatic

使用/index.html

设置静态Matic项目

@slug = current_page.gsub(/\.html/, '')

返回"/index(.html)",但应该是/index


更改字词更正: - @slug = current_page.gsub("/", "").gsub(".html", ""),如下所示:

https://github.com/adamstac/staticmatic-bootstrap/blob/master/src/helpers/application_helper.rb

1 个答案:

答案 0 :(得分:1)

要在删除html后删除开头“/”,只需执行此操作(这将在一个命令中执行):

current_page.gsub(/\.html/, '').gsub(/\//,''))
相关问题