How Do I Access an Object's Properties From a Template?

前端 未结 1 1708
囚心锁ツ
囚心锁ツ 2021-01-12 05:47

According to http://handlebarsjs.com/expressions.html, I should be able to do this:

{{article.title}}

But I can\'t see

相关标签:
1条回答
  • 2021-01-12 06:34

    You should use {{#with object}}

    If your object is something like :

    my_object = {
        name : 'my_name',
        prop : 'my_prop'
    }
    

    In your template your can do :

    <template name="my_template">
        {{#with my_object}}
            <p>Name is {{name}}<p>
            <p>Prop is {{prop}}</p>
        {{/with}}
    </template>
    

    Here you go :)

    0 讨论(0)
提交回复
热议问题