Guest User

Untitled

a guest
Jan 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. /*
  2. * Define use of jade templating language
  3. */
  4. require.extensions['.jade'] = function (module, filename) {
  5. var content = fs.readFileSync(filename, 'utf8');
  6. var name = path.basename(filename).replace(/\..+$/, '');
  7.  
  8. try {
  9.  
  10. // Replace this with whatever your template engine requires to compile
  11. // templates. Be sure to assign the function to module.exports
  12. module.exports = jade.compile(content, {});
  13. Bones.plugin.add(module.exports, filename);
  14. } catch (err) {
  15.  
  16. // Show error message when template compilation failed.
  17. var lines = err.message.split('\n');
  18. lines.splice(1, 0, ' in template ' + filename);
  19. err.message = lines.join('\n');
  20. throw err;
  21. }
  22.  
  23. // The .register() method is called when the template is added to a server
  24. module.exports.register = function (app) {
  25. if (app.assets) {
  26. app.assets.templates.push({
  27. filename: filename,
  28. // Replace this with whatever you want to send to the client.
  29. content: 'template = ' + jade.compile(content, { client: true, compileDebug: false } ) + ';'
  30. });
  31. }
  32. };
  33. };
Add Comment
Please, Sign In to add comment