既然
remarkable-regexp是npm模块,我相信将其与ember-cli集成的最佳方法是使用ember-
browserify。
在ember-cli应用程序中,您可以运行以下命令安装插件
npm install --save-dev ember-browserify
因此,您可以使用ES6 import导入模块,方法是在模块前面加上前缀
npm:
import Remarkable from 'npm:remarkable';import Plugin from 'npm:remarkable-regexp';var plugin = Plugin( // regexp to match /@(w+)/, // this function will be called when something matches function(match, utils) { var url = 'http://example.org/u/' + match[1] return '<a href="' + utils.escape(url) + '">' + utils.escape(match[1]) + '</a>' })new Remarkable() .use(plugin) .render("hello @user")// prints out:// <p>hello <a href="http://example.org/u/user">user</a></p>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)