I'm trying to use Markdown-it in Ember Helper. First I installed it with Bower and tried to import it.
app.import('bower_components/markdown-it/dist/markdown-it.js');
In helper:
import MarkdownIt from "markdown-it";
This is showing error Could not find module: markdown-it
. Then I tried to use Ember-browserify and install Markdown-it
via npm. I tried to import it in helper
import MarkdownIt from "npm:markdown-it";
export default Ember.Handlebars.makeBoundHelper(function(input){
var result = MarkdownIt.render(input);
return new Ember.Handlebars.SafeString(result);
});
This is showing error TypeError: a.default.render is not a function
.
I also tried
import MarkdownIt from "npm:markdown-it";
export default Ember.Handlebars.makeBoundHelper(function(input){
var md = new MarkdownIt();
var result = md.render(input);
return new Ember.Handlebars.SafeString(result);
});
This is showing Error: Could not find module npm:markdown-it
imported from my-new-app/helpers/format-markdown
The library you're trying to use doesn't provide a name for itself when using AMD, so there's no way to import
it via a name. See https://github.com/ember-cli/ember-cli/issues/770 for more information about this.
It does look like "markdown-it" also exposes itself as a global, so you can always access it that way: