Node.js Swig-nodejs-使用空格

Node.js Swig-nodejs-使用空格,node.js,swig-template,Node.js,Swig Template,使用Swig v.1.2.2时,我在尝试使用带有包含空白的键的对象时遇到问题 例如,如何在Swig模板中使用以下对象 { _lang: 'english', Title: 'This is the title', Sub_title: 'This is the sub title', Feature_1: 'This is the feature 1', 'Feature 2': 'This is the feature 2', 'Feature 3': 'This is the feature

使用Swig v.1.2.2时,我在尝试使用带有包含空白的键的对象时遇到问题

例如,如何在Swig模板中使用以下对象

{ _lang: 'english',
Title: 'This is the title',
Sub_title: 'This is the sub title',
Feature_1: 'This is the feature 1',
'Feature 2': 'This is the feature 2',
'Feature 3': 'This is the feature 3',
'Feature 4': 'This is the feature 4',
'Feature 5': 'This is the feature 5',
'Feature 6': 'This is the feature 6',
Footer: 'This is the footer' }
因此,对于所有没有空格的键,我可以轻松地使用它们,例如:

<p> {{Feature_1}}</p>

如何对功能2等执行类似操作?

除非将这些项目嵌套一层,否则不支持此操作:

{
    Title: 'This is the title',
    Features: {
        'Feature 1': 'This is the feature 1',
        'Feature 2': 'This is the feature 2',
        'Feature 3': 'This is the feature 3',
        'Feature 4': 'This is the feature 4',
        'Feature 5': 'This is the feature 5',
        'Feature 6': 'This is the feature 6',
    }
}
然后您可以这样访问:

<p>{{ Features['Feature 1'] }}</p>
或循环:

{% for key,feature in Features %}
    <p>{{ feature }}</p>
{% endfor %}

此外,作为一般经验法则,人们普遍认为使用点符号可访问的键更快捷、更容易,不需要引号。

点符号的意思是简单的名称,因为如果使用带点的键,它也会被引用,以免与对象的字段混淆。这也有点糟糕,你将无法将其用于本地化目的,关键是英文全文,这就是整个想法。。。您知道其他节点模板系统能够做到这一点吗?