如何从控制台或其他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屋!
查看全文