view.js 415 B

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