Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

render bug fixed

  • Loading branch information...
commit e8e3b99b3317417bc017c8f9001a1fd584576c46 1 parent 32b5b76
@jindw authored
Showing with 12 additions and 6 deletions.
  1. +12 −6 lite-engine.js
View
18 lite-engine.js
@@ -81,18 +81,24 @@ function doRender(tpl,model,response){
response.write(tpl.staticPrefix,'utf-8');
if(typeof model == 'function'){
//TODO,需要引擎级别实现异步,这里知识兼容一下接口
- renderAsync(tpl,callback,response)
+ renderAsync(tpl,model,response)
}else{
- var rtv = tpl.render(model);
+ try{
+ var rtv = tpl.render(model);
+ }catch(e){
+ rtv = require('util').inspect(e,true);
+ }
response.end(rtv);
}
}
-function renderAsync(tpl,callback,response){
- callback(function(model){
- if(tpl){
+function renderAsync(tpl,modelLoader,response){
+ modelLoader(function(model){
+ try{
var rtv = tpl.render(model);
- response.end(rtv);
+ }catch(e){
+ rtv = require('util').inspect(e,true);
}
+ response.end(rtv);
});
}
function Template(code,config,staticPrefix){
Please sign in to comment.
Something went wrong with that request. Please try again.