在 angular-meteor 中包含降价的最佳方法是什么
what is the best way to include markdown in angular-meteor
我想将 markdown
文本作为我的模板的一部分。
我正在使用 angular-meteor
,我看到了 2 个备选方案:
- 安装 angular 的软件包,例如 angular-markdown-directive
- 包含一个没有
.ng.html
后缀的文件并像这样使用 meteor 的降价:{{#markdown}}{{>innerPreview}}{{/markdown}}
还有其他选择吗?它会工作吗?哪个更好?
我在 hypercube's package 的 atmosphere 中创建了程序包 oshai:angular-marked
。你可以在大气中搜索它。
有一次我使用摊牌创建了自己的指令,但后来我决定摆脱它,只使用 Meteor 已经附带的指令。
第一件事。我有一个名为 meteorTemplates.html
的 .html 文件。我只是将我使用的所有流星模板放在这里。我只有2个而且很小。
无论如何。模板如下所示:
<template name="mdTemplate">
{{#markdown}}{{md}}{{/markdown}}
</template>
在我的控制器中我有:
$scope.my.markdown = '#Markdown';
根据 angular-meteor 文档:
The meteor-include directive holds the Angular scope of the directive as the as Template.currentData of the Meteor template.
所以,Template.currentData == $scope.
然后在模板助手中我将使用 Template.currentData() 就像 $scope.
Template.mdTemplate.helpers({
md: function() {
return Template.currentData().getReactively('my.markdown');
}
});
我的 ng.html 文件将如下所示:
<div id="markdown-preview">
<meteor-include src="mdTemplate"></meteor-include>
</div>
我想将 markdown
文本作为我的模板的一部分。
我正在使用 angular-meteor
,我看到了 2 个备选方案:
- 安装 angular 的软件包,例如 angular-markdown-directive
- 包含一个没有
.ng.html
后缀的文件并像这样使用 meteor 的降价:{{#markdown}}{{>innerPreview}}{{/markdown}}
还有其他选择吗?它会工作吗?哪个更好?
我在 hypercube's package 的 atmosphere 中创建了程序包 oshai:angular-marked
。你可以在大气中搜索它。
有一次我使用摊牌创建了自己的指令,但后来我决定摆脱它,只使用 Meteor 已经附带的指令。
第一件事。我有一个名为 meteorTemplates.html
的 .html 文件。我只是将我使用的所有流星模板放在这里。我只有2个而且很小。
无论如何。模板如下所示:
<template name="mdTemplate">
{{#markdown}}{{md}}{{/markdown}}
</template>
在我的控制器中我有:
$scope.my.markdown = '#Markdown';
根据 angular-meteor 文档:
The meteor-include directive holds the Angular scope of the directive as the as Template.currentData of the Meteor template.
所以,Template.currentData == $scope.
然后在模板助手中我将使用 Template.currentData() 就像 $scope.
Template.mdTemplate.helpers({
md: function() {
return Template.currentData().getReactively('my.markdown');
}
});
我的 ng.html 文件将如下所示:
<div id="markdown-preview">
<meteor-include src="mdTemplate"></meteor-include>
</div>