1
經過大量的努力,我已經實現了handlebarsjs到一個測試站點,用戶在輸入數據時顯示它。handlebarsjs - 如何使用include代替重複代碼
要以不同的模板樣式顯示用戶輸入,我必須以同樣的形式多次重複相同的handlebarsjs代碼。
有沒有辦法將重複的句柄代碼放在一個外部頁面,然後包括這個外部頁面代替重複的句柄代碼?
我不確定語法,或者即使這種方法可能與handlebarsjs(我嘗試了幾件事 - 但不能得到這個工作)。
這裏是被剔除重複的代碼,我有:
{{# if address_style_one_line }}
{{! address is to be displayed across one line - replaced line breaks with line space }}
{{# if address_style_01 }}
....
{{else}}
{{# if address_style_02 }}
....
{{else}}
{{! address is to be displayed across more than one line - use this format as the template for the address scross one line style }}
{{# if address_style_01 }}
....
{{else}}
{{# if address_style_02 }}
....
{{/if}}
VLS - 感謝您的幫助。 – user3354539