如何在 Sinatra 中制作布局模板? [英] How to make a layout template in Sinatra?

查看:40
本文介绍了如何在 Sinatra 中制作布局模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Sinatra 的新手,我不知道把我的应用程序布局放在哪里.

I'm new to Sinatra and I can't figure out where to put my application layout.

我见过使用

# app code    
__END__

@@layout
  %html
    = yield

但我希望布局在它自己的 .haml 文件中.

But I'd like the layout to be in it's own .haml file.

布局文件应该取什么名字?应该放在什么目录?

What should the layout file be named? What directory should it be placed in?

推荐答案

如果您还没有,请创建一个文件夹,您的 sinatra 脚本所在的文件夹称为...

If you haven't already, create a folder where your sinatra script lives called...

views/

然后把你的布局放在那里,调用你的布局

and put your layout in there, call your layout

layout.haml

或您想使用的任何扩展名(例如 .erubis).

or whatever extension (e.g. .erubis) you'd like to use.

这篇关于如何在 Sinatra 中制作布局模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆