對於handlebars(版本1.0.0-rc.3)模板,我傳遞了兩個變量,一個是json,另一個是包含當前語言的字符串。如何訪問Handlebars模板中的if語句中的數據
self.template = template({ data: self.model, lang:self.lang });
然後在模板文件中,我有以下結構:
{{#each data}}
//this is working
{{../lang}}
{{#if this.title}}
{{this.desc}}
//i've tried this
{{../lang}}
//and this
{{lang}}
{{/if}}
{{/each}}
...但我無法訪問if語句裏面的郎值。我究竟做錯了什麼?
檢查我提供您的解決方案,看是否適合你不是註冊一個幫手更好。 – diosney