如何将此html文件转换为web2py布局文件?

时间:2016-04-16 09:02:20

标签: layout web2py

http://ideone.com/g9gdkK

根据文档,我必须将hrefs和srcs更改为URL表单(将文件移动到静态文件夹后)并将{{include}}添加到正文,但输出不正确。

  <link href="css/bootstrap.min.css" rel="stylesheet">

  <link href="{{=URL('static', 'css/bootstrap.min.css')}}" rel="stylesheet">

原始的html代码位于上面的链接中。

请帮忙。

1 个答案:

答案 0 :(得分:1)

文件views/layout.html定义了您网站的整体结构。

查找{{include}} - 此时,视图(或视图中的HTML代码)将包含在整体结构中。

如果您有控制器test,并且output中的函数http:\\www.whatever.com\test\output

def output():
    # Do something
    return dict(...)

Web2py正在output.html中查找相应的视图views/test,您可以使用返回的内容(如果您愿意)执行操作。

此HTML文件可能如下所示:

{{extend 'layout.html'}}
<div>
    <!-- Your contents -->
</div>

有关此主题的更多信息,请参阅page-layout section of the official documentation