forked from cloudbeer/zp-node-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.html
90 lines (63 loc) · 2.04 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<h1>zp-node-framework</h1>
<p>开发进行中</p>
<p>这个项目是使用 nodejs 做的 web framework。
目前包含以下功能:</p>
<h1>URL 路由</h1>
<p>规则如下:</p>
<ul>
<li>如果在路由表里配置了路由,则按照路由的规则进行。</li>
</ul>
<p>使用方法:</p>
<p><code>nodejs
zippy.routes["/test"] = function (req, res) {
res.html("我是路由映射过来的。");
}
</code></p>
<ul>
<li>然后寻找 controllers 目录下的文件,进行类似 asp.net MVC 方式的路由。</li>
</ul>
<p>使用方法:</p>
<p><code>nodejs
require('../viewengine');
exports.Home = {
index: function (req, res) {
res.mesh('home_index', { req: req, list: 'i am a list' }, 'layout/main');
},
index1: function (req, res) {
res.json({site:1});
}
}
</code></p>
<ul>
<li>如果以上两个规则没有,就直接寻找相应路径的静态文件。(这个在正式环境下应该由 webserver 完成)。</li>
</ul>
<h1>模版引擎</h1>
<ul>
<li>SiteMesh 的方式,主要是借用了 cheerio 库,对 layout 和页面进行合并。</li>
</ul>
<p>使用方法:</p>
<p>在模版里</p>
<p><code>html
<mesh id='content' />
</code></p>
<p>在页面里</p>
<p><code>html
<div id='content'>
</code></p>
<ul>
<li><p>使用了 vash 模版引擎,主要是觉得 Razor 模版很不错。 <strong>好吧,我承认我是该死的 asp.NET 程序员。</strong></p></li>
<li><p>明白了个中道理,使用其他模版引擎也是易如反掌好么。</p></li>
</ul>
<h1>其他功能特点</h1>
<ul>
<li>做了一个 controllers 目录的监控,可以在改动 controllers 的时候不重启。</li>
</ul>
<h1>计划中</h1>
<ul>
<li><p>Session 的支持(内存,memcached, redis)</p></li>
<li><p>优化:模版和页面的 cache</p></li>
</ul>
<hr />
<p>Notice: this.project.isNotAccomplished();</p>
<p>请注意:这个还在开发中,仅作为参考,不要贸然使用在项目中,出问题了,作者概不负责。</p>
<hr />