Closed marcoow closed 10 years ago
forgive a silly question, but did you try
var marked = require('../vendor/marked');
var Handlebars = require('handlebars');?
module.exports = function(string) {
return new Handlebars.SafeString(marked(srting));
}
Yep, that doesn't work (the handlebar file is somewhere on node_modules). I'd say it would be best if the helper loader would somehow make Handlebars available for the helpers?
Am 24.02.2014 um 19:08 schrieb patrick kettner notifications@github.com:
forgive a silly question, but did you try
var marked = require('../vendor/marked'); var Handlebars = require('handlebars');?
module.exports = function(string) { return new Handlebars.SafeString(marked(srting)); } — Reply to this email directly or view it on GitHub.
Im still not quite clear on what is going on here - what is the module you are exporting in relation to this helper?
Not sure what you mean - above code is the complete helper; marked is this: https://github.com/chjj/marked
Sorry, wasn't very clear.
if your project dir is /foo
, then this helper (ie grunt-compiler-handlebars) is at /foo/node_modules/grunt-compile-handlebars
.
Where is the file you listed
var marked = require('../vendor/marked');
module.exports = function(string) {
return new Handlebars.SafeString(marked(srting));
}
relative to the other two files?
I see; fortunately it's an open source project, so you can look at the code here: https://github.com/simplabs/ember-simple-auth/tree/es6-modules
I meant where in the file system does this file reside relative to this helper?
it's here: https://github.com/simplabs/ember-simple-auth/tree/es6-modules/docs/theme/helpers, "marked" is in a different directory: https://github.com/simplabs/ember-simple-auth/tree/es6-modules/docs/theme/vendor - both directories are in subdirectories in the project root
The best thing to do in this situation would be to add Handlebars as a dependency in your package.json, and then require('handlebars')
in your code like I mentioned above.
Sometimes it's actually so simple ;) Thanks!
my pleasure!
I'm using marked to render markdown via a helper:
But of course Handlebars is not defined. What's the suggested way to return a safe string from a helper?