简体   繁体   English

如何在meteor.js中找到模板变量的来源

[英]how to find where template variable is coming from in meteor.js

In someone elses meteor app code they have some thing like the following: 在其他人的流星应用程序代码中,它们具有如下内容:

<template name="null">
   {{>main}}
</template>

<template name="main">
    {{#if some_user}}
       text or whatever
    {{/if}}
</template>

But no where in their client code do they have a Template.null and they define only one helper for main eg 但是在他们的客户代码中没有地方有Template.null,并且它们只为main例如定义一个助手

Template.main.mode
   return Session.get('mode')

some_user does exist but I can't figure out where it is coming from. some_user确实存在,但我不知道它来自哪里。 I searched through all the projects files and currentUser is only defined in the template so I assume its the property of some object that is returned. 我搜索了所有项目文件,并且currentUser仅在模板中定义,因此我假设它是返回的某些对象的属性。 What is the best way to figure out where it is coming from? 弄清其来源的最佳方法是什么?

This is likely a package that is installed. 这可能是已安装的软件包。 Simply search the entire codebase including the directories under the .meteor folder for all calls to publish and you'll find it. 只需搜索整个代码库(包括.meteor文件夹下的目录),即可找到所有要发布的调用,您将找到它。

If the some_user helper is not defined anywhere in the code, then it's stub (incomplete) code. 如果在代码的任何地方都未定义some_user帮助器,则它是存根(不完整)代码。

To answer your other question about subscribe for core modules. 要回答有关订阅核心模块的其他问题。 If you have the default autopublish package installed, then the entire database is published including the user database. 如果安装了默认的自动发布程序包,则将发布整个数据库,包括用户数据库。 If you remove the autopublish package, then you'll only be able to see the user information for the logged in user. 如果删除自动发布程序包,则只能查看已登录用户的用户信息。 Unless you publish and subscribe to it. 除非您发布并订阅。

I've been building a new app with Meteor for about a month. 我已经用Meteor开发了一个新的应用程序大约一个月了。 So I'm no where near an expert, but I hope this helps. 所以我离专家很近,但我希望这会有所帮助。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM