如何从控制台或其他 JS 代码调用 Meteor 模板助手? [英] How do you call a Meteor template helper from the console or other JS code?
本文介绍了如何从控制台或其他 JS 代码调用 Meteor 模板助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Meteor 中定义了一个模板助手,比如
I've defined a template helper in Meteor, say
Template.postsList.helpers({
filteredPosts: function getPosts() {
return Posts.find(...);
}
});
如何从控制台调试该模板助手,以及如何从应用中的其他代码中重用它?
How can I debug that template helper from the console, and how can I reuse it from other code in the app?
推荐答案
想要从应用程序的其他地方调用帮助程序建议您应该在函数中将其分解.
Wanting to call the helper from elsewhere in the app suggests that you should factor it out in a function.
要快速调试帮助程序,请在客户端控制台中进行评估:
To quickly debug the helper, evaluate this in the client console:
Template.postsList.__helpers.get('filteredPosts')(...parameters);
有一个包可能有助于调试模板和模板助手:prasad19sara:client-debugger.
这篇关于如何从控制台或其他 JS 代码调用 Meteor 模板助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文