如何查看手柄模板中的所有可用变量 [英] How to see all available variables in handlebars template

查看:152
本文介绍了如何查看手柄模板中的所有可用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事我的第一个Ember.js应用程序,并且连接所有的点都有麻烦。如果我可以看到给定的handlebars模板中可用的所有变量,这将是非常有帮助的。



有一个相关的问题,但是你必须知道在范围内使用它:
如何在Handlebars模板中添加console.log()JavaScript逻辑?



如何输出 所有 变量?

解决方案

一个好的选择是调试this的值使用Handlebars助手的模板:
1。

  {{each each}} 
{{log这个}}
{{/ each}}


2。类似于@watson建议

  {{每个}} 
{{debugger}}
{ / each}}

然后在D中钻取本地范围变量ev工具





或者3.您可以直接从Controller init方法内记录事项,例如:

  App.UsersController = Ember.ArrayController.extend({
init:function(){
console.log(this);
console.log(this.getProperties('。'));
}
});


I'm working on my first Ember.js app and am having some trouble connecting all the dots. It would be really helpful if I could just see all the variables available within a given handlebars template.

There is a related question, but you have to know the variable that is in scope to use it: How do I add console.log() JavaScript logic inside of a Handlebars template?

How can I output all the variables?

解决方案

a good option is to debug the value of 'this' in a template using the Handlebars helpers: 1.

{{#each}}
    {{log this}}    
{{/each}}

or, 2. similar to @watson suggested

{{#each}}
    {{debugger}}
{{/each}}

and then drill in to the Local Scope Variables for 'this' in the Dev Tools

or alternatively, 3. you could log things directly from inside your Controller init method, such as:

App.UsersController = Ember.ArrayController.extend({
    init: function() {
        console.log(this);
        console.log(this.getProperties('.'));
    }
});

这篇关于如何查看手柄模板中的所有可用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆