functions.js 433 B

12345678910111213141516171819202122
  1. /**
  2. * Module dependencies.
  3. */
  4. var ejs = require('../')
  5. , fs = require('fs')
  6. , path = __dirname + '/functions.ejs'
  7. , str = fs.readFileSync(path, 'utf8');
  8. var users = [];
  9. users.push({ name: 'Tobi', age: 2, species: 'ferret' })
  10. users.push({ name: 'Loki', age: 2, species: 'ferret' })
  11. users.push({ name: 'Jane', age: 6, species: 'ferret' })
  12. var ret = ejs.render(str, {
  13. users: users,
  14. filename: path
  15. });
  16. console.log(ret);