Open giuliandrimba opened 11 years ago
Is there a way to wrap a text file in a CJS module to be required as a text dependency? Something like the RequireJS text plugin does.
This is useful for rendering the HTML in the client side, eg:
<!-- template.js.tmpl--> <p> Template </p>
Wrap the above file as a CJS module:
# template.js module.exports = "<p> Template </p>"
Load the template module, and append it to the DOM.
# user.module.js.coffee template = require "./template" class User render:()-> $("body").append template
I made an adjustment in my fork to show how it would work (it is actually working) here.
What do you think? What would be the best approach for this?
Is there a way to wrap a text file in a CJS module to be required as a text dependency? Something like the RequireJS text plugin does.
This is useful for rendering the HTML in the client side, eg:
Wrap the above file as a CJS module:
Load the template module, and append it to the DOM.
I made an adjustment in my fork to show how it would work (it is actually working) here.
What do you think? What would be the best approach for this?