Friday, March 09, 2007

First, design a Basic Layout

PROCESS
当开始design views工作时,我们首先设计一个default layout,我个人更倾向于使用
Basic Layout。这个"基础版面"包含了我们在每个view上都需要显示的元素。然后,我们再开始设计每一个单独的view。

Basic Layouts are like meta-templates. They contain general template code that surrounds the specific template code of one or more views. Basic Layout generall contains all kinds of site-wide elements that it would be a nuisance to have to insert individually into every template file.
A typical basic layout might include a header bar, a menu bar, a copyright notice, etc.
The basic layout also contains appropriate XML declarations—again, saving you the trouble of putting them in every template file.

HOW-TO-USE basic layout?
The layout uses a “magic” variable @content_for_layout at the point where you want the specific view inserted.

创建一个文件application.rhtml,放到app/views/layouts 目录下,这就成了整个webapp的default layout。Rails默认application.rhtml为“全站默认版面”。COOL ! Convention over Configuration

No comments: