view.js 412 B

123456789101112131415161718192021
  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;
  7. }
  8. if(FILE.existsSync(src)){
  9. var data = FILE.readFileSync(src,'UTF-8');
  10. this.html = EJS.render(data,this.params);
  11. }else{
  12. return null;
  13. }
  14. return this;
  15. }
  16. module.exports = View;