2012-10-29 22 views

cevap

17

Makroda farklı #nested öğeleriniz olamaz, her kullanım aynı metni verir.

Makronuzda çok değişkenli bölümler olmasını hedefliyorsanız, #assign öğesini kullanabilirsiniz.

bir sayfa

Örnek #macro gövde, başlık ve alt bilgi içeriğini tanımlamak için izin: Bu durumda, #assign elemanı kullanılarak her bölüm tanımlayabilir

<#macro pageTemplate header="" footer=""> 
    ${header} 
    <#nested > 
    ${footer} 
</#macro> 

(ama kuşkusuz birden adlı sahip #nested öğesi daha iyi olurdu).

<#assign headerContent> 
    This is the header. 
</#assign> 
<#assign footerContent> 
    This is the footer. 
</#assign> 
<@pageTemplate header=headerContent footer=footerContent> 
    This is the nested content. 
</@pageTemplate> 

elde edilen çıkış olacaktır:

This is the header. 
This is the nested content. 
This is the footer.