赶上公司去Windows化,有一大波.net站点需要转成Node.js,于是自己就顺便琢磨一个通用的Node版MVC框架。
经过几天的努力,beta版终于面世了!因为其高性能的特点,特地命名node-eagle
github地址:https://github.com/sqzhuyi/node-eagle
- npm install node - eagle
- <body>
- {% include "./_header.html" %} {% block body %}
- <div>
- default content
- </div>
- {% endblock %} {% include "./_footer.html" %}
- </body>
- {% extends "../shared/_layout.html" %}
- {% block body %}
- <div class="body">
- {{{ content }}}
- </div>
- {% endblock %}
1、在Node启动文件中加入以下代码:
- const Koa = require("koa");
- const app = new Koa();
- const eagle = require("node-eagle");
- const config = require("./config");
- eagle(app, config);
- app.listen(config.port, config.host, function(){
- console.log(`app start at ${config.host}:${config.port}`);
- });
2、按照MVC规则创建站点文件,如下:
- website
- ├ controllers
- │ └ home.js
- ├ views
- │ └ home
- │ └ index.html
- ├ config.js
- └ route.js
3、最重要的是,一定要看这个Demo: https://github.com/sqzhuyi/node-eagle-demo
来源: http://www.cnblogs.com/sqzhuyi/p/node-eagle.html