在手柄模板中隐藏关键字 [英] Escape keyword in the handlebar template

查看:116
本文介绍了在手柄模板中隐藏关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象集合(MyApp.instrsController,一个ArrayController),每个对象都有一个名为action(一个浮点数)的属性,我该如何使用handlebars模板显示?



以下是我试过的代码:

 < ul> 
{{#each MyApp.instrsController}}
< li> {{action}}< / li>
{{/ each}}
< / ul>

但由于'action'是一个'关键字',它会引发javascript运行时错误'options is undefined'



感谢高级。

解决方案

我认真地建议你只需更改属性的名称。
您正在花时间努力解决您的域名并不重要的问题。



YAGNI。 KISS。



在编程中学习的最大的教训是如何完成和完成任务,而不是如何操作javascript,而不是在使用保留关键字时引用。如果你没有一个看起来很困难的脆弱解决方案,你将会更快乐。



由于这是一个浮点数,我可以建议你使用actionLevel吗?


I have a collection of objects (MyApp.instrsController, an ArrayController) and each object has a property called 'action' (a float number), how can I display it using the handlebars template?

Below is the code I've tried:

<ul>
{{#each MyApp.instrsController}}
   <li>{{action}}</li>
{{/each}}
</ul>

But since 'action' is a 'keyword', it throws javascript runtime error 'options is undefined'.

Thanks in advanced.

解决方案

I seriously suggest that you just change the name of the property. You are spending time working on a problem that is not core to your domain.

YAGNI. KISS.

The biggest lesson to learn in programming is how to get things made and done rather than how to manipulate javascript into not throwing a snit over your use of a reserved keyword. You will be happier later if you don't have a fragile solution that looks tricky to understanc

Since this is a float, can I suggest you use "actionLevel"?

这篇关于在手柄模板中隐藏关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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