Permalink
Browse files

edit

  • Loading branch information...
1 parent bf1e55f commit e8634abbd8d932033cf0f689e17e97117031b9ad lloydsheng committed with anandology Jun 11, 2010
Showing with 12 additions and 12 deletions.
  1. +12 −12 cookbook/layout_template.zh-cn.md
View
24 cookbook/layout_template.zh-cn.md
@@ -1,23 +1,23 @@
---
layout: default
-title: Site Layout Template
+title: 站点布局模板
---
-# Site Layout Template
+# 站点布局模板
-### Problem
+### 问题
-How do I use a site-wide base template that displays across every page? (In other frameworks, this is called template inheritance.)
+如何让站点每个页面共享一个整站范围的模板?(在某些框架中,称为模板继承,比如ASP.NET中的母版页)
-### Solution
+### 方法
-This can be done using the base attribute:
+我们可以用 base 属性来实现:
render = web.template.render('templates/', base='layout')
-Now if you do something like `render.foo()` it will render the `templates/foo.html` template and then wrap it in the `templates/layout.html` template.
+现在如果你调用`render.foo()`方法,将会加载`templates/foo.html` 模板,并且它将会被 `templates/layout.html`模板包裹。
-The format for "layout.html" should be a simple template that takes one variable. For example:
+ "layout.html" 是一个简单模板格式文件,它包含了一个模板变量,如下:
$def with (content)
<html>
@@ -29,11 +29,11 @@ The format for "layout.html" should be a simple template that takes one variable
</body>
</html>
-If you don't want to use the base template for something, just create a second render object without the base attribute, like:
+在某些情况,如果不想使用基本模板,只需要创建一个没有base属性的reander对象,如下:
render_plain = web.template.render('templates/')
-###Tip: Page title is set in other template files which are then used by the layout (layout.html). Example:
+###Tip: 在布局文件(layout.html)中定义的页面标题变量,如何在其他模板文件中赋值,如下:
#####templates/index.html
$var title: This is title.
@@ -51,7 +51,7 @@ If you don't want to use the base template for something, just create a second r
</body>
</html>
-###Tip: Add css files in other template files. Example:
+###Tip: 在其他模板中引用css文件,如下:
####templates/login.html
$var cssfiles: static/login.css static/login2.css
@@ -75,7 +75,7 @@ If you don't want to use the base template for something, just create a second r
</body>
</html>
-The HTML output code looks like below:
+输入的HTML代码如下:
<link rel="stylesheet" href="static/login.css" type="text/css" media="screen" charset="utf-8"/>
<link rel="stylesheet" href="static/login2.css" type="text/css" media="screen" charset="utf-8"/>

0 comments on commit e8634ab

Please sign in to comment.