view.js 433 B

12345678910111213141516171819202122
  1. var View = function(src,params){
  2. if(!src) return null;
  3. this.html = '';
  4. this.params = params?params:{};
  5. if(!src.match(Core.Path.View)){
  6. src = Core.Path.View + src + '.html';
  7. }
  8. try{
  9. FILE.statSync(src);
  10. var data = FILE.readFileSync(src,'UTF-8');
  11. this.html = EJS.render(data,this.params);
  12. }catch(e){
  13. return null;
  14. }
  15. return this;
  16. }
  17. module.exports = View;