morepath的mako模板绑定
more.mako的Python项目详细描述
#more.mako
`more.mako`是[morepath](http://morepath.readthedocs.io)的扩展,在使用`.mako`扩展时添加[mako](http://makotemplates.org)
模板支持。
示例用法:
``python
from more.mako import mako app
class app(makoapp):
>
@app.path(path='persons/{name}')
class-person(object):
>def-init(self,name):
self.name=name
@app.template\u directory()
>def-get-template\u template\u template目录():
>返回“模板”
@app.html(model=person,template='person.mako')
是的self.name}
```
,然后在“templates”子目录中的“person.mako”:
``html
<;html>;
<;body>;
<;p>;您好{name}!<;/p>;
<;/body>;
<;/html>;
````
您还可以使用特殊语法从模板中呈现def,如以下示例:
``python
@app.html(model=root,template='defs hello.mako')
def hello():
返回{name':'world}
`````
,然后在'defs.mako`:
```html
<;%def name='hello(name)>;
<;p>;hello${name}!<;/p>;
<;/%def>;
```
请注意,mako文档对
mako模板使用“.html”扩展,而此扩展使用“.mako”。
例如:
`` python
@app.setting_section(section='mako')
def get_setting_section():
返回{
'默认_过滤器':['h',
'格式异常':true
}
````
有关mako配置选项的详细信息,请参阅[mako api
文档](http://docs.makotemplates.org/en/latest/usage.html api reference)。
0.1.0(2016-09-08)
----
-initial public release
`more.mako`是[morepath](http://morepath.readthedocs.io)的扩展,在使用`.mako`扩展时添加[mako](http://makotemplates.org)
模板支持。
示例用法:
``python
from more.mako import mako app
class app(makoapp):
>
@app.path(path='persons/{name}')
class-person(object):
>def-init(self,name):
self.name=name
@app.template\u directory()
>def-get-template\u template\u template目录():
>返回“模板”
@app.html(model=person,template='person.mako')
是的self.name}
```
,然后在“templates”子目录中的“person.mako”:
``html
<;html>;
<;body>;
<;p>;您好{name}!<;/p>;
<;/body>;
<;/html>;
````
您还可以使用特殊语法从模板中呈现def,如以下示例:
``python
@app.html(model=root,template='defs hello.mako')
def hello():
返回{name':'world}
`````
,然后在'defs.mako`:
```html
<;%def name='hello(name)>;
<;p>;hello${name}!<;/p>;
<;/%def>;
```
请注意,mako文档对
mako模板使用“.html”扩展,而此扩展使用“.mako”。
例如:
`` python
@app.setting_section(section='mako')
def get_setting_section():
返回{
'默认_过滤器':['h',
'格式异常':true
}
````
有关mako配置选项的详细信息,请参阅[mako api
文档](http://docs.makotemplates.org/en/latest/usage.html api reference)。
0.1.0(2016-09-08)
----
-initial public release