阅 读 文 章

snakelets 文档,我翻译了一部分。

[来源:网上转载 (http://www.chinaunix.net) | 作者:网友(瘦青蛙) | 时间:2007-05-27 | 浏览:人次 ]


为了避免您在网页中一遍又一遍的使用同样的代码,您应该创建 一般布局和公共部分或者创建模板页面。其他 Ypage页面只需要包含模板声明就可以了,页面中只包含自己需要的内容就可以了。模板页面中可以声明公共header,菜单,body框架,页脚 和 script/css 连接,其他页面只需要定义 body中的内容。如果您想更改body框架,您只需要更新您的模板页面框架就可以了。您可以在任何一个Ypage中定义 模板页面,也可以对webapp的defaultPageTemplate进行设置来为所有页面定义全局模版。


As a template page is just an Ypage, you can do all sorts of dynamic page creation code inside it. It is even possible to pass page-specific variables from every templated ypage into the template page, so that you may use that in the template (example: to give every page a page-specific title, where the title is defined in the templated page). These template args can be simple and static, or dynamically created using a special page method.
模板页面和 Ypage一样,您可以在其中插入任何动态页面创建代码。当然也可以传送 page-specific (页面指定) 参数从一个模版 ypage到另一个模板页面,以便您在模板中使用(例如:为每一个页面添加一个以近改模板中定义了的 page-specific 名称)。这些模板参数可以是很简单的,静态的或者被特殊页面方法创建的动态参数。


[size=18]Other ways of avoiding page code duplication, and structuring your page code[/size]

Another possibility is to put parts of a page that are used over and over again inside a separate Ypage that is not accessed directly. Rather, you include it inside other Ypages that want to use it. For instance: if you find that you are building a complicated table structure on several different pages, you can put the table code in a separate Ypage file and include it in the other pages. If you want to change the table, you only have to make changes in one file, and the table is changed on all pages.
另外一种可能性就是 页面的一部分在单独的Ypage中被重复使用,而且不能直接访问(在其他页面中使用你想要使用的页面的某一部分?)。相当于你将你想用的部分include到其他Ypage中。比如:您发现您正在很多不同页面中建立一个复杂的表格结构,您可以将表格代码放到一个单独的Ypage文件中,在其他页面中include它就可以了。如果您想修改table您只需要修改一个Ypage文件,而不需要做大量修改工作。
论坛热门帖子: [lch203] 写得蛮好的linux学习笔记(10-21)
[黑马制造] 学习java的30个目标(10-19)
[笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19)
[udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18)
[沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18)
TAG标签: 翻译 文档 使用 可以 页面 URL 如果 文件 webapp 一个

最新评论 共有1位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.