Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于小型开发人员文档应用程序,我想设置一个 Sinatra 应用程序来仅提供 HAML 文件。在 CSS 文件和图像的路由之后,我想要一个尝试为您请求的任何路径加载 HAML 文件的路由。
例如:
/index
views/index.haml
/this/page/might/exist
views/this/page/might/exist.haml
我将如何指定这条路线?
看起来会这样做:
get '/*' do viewname = params[:splat].first # eg "some/path/here" if File.exist?("views/#{viewname}.haml") haml :"#{viewname}" else "Nopers, I can't find it." end end