2012-10-29 12 views

Odpowiedz

17

Nie możesz mieć różnych elementów #nested w makrze, każde użycie spowoduje wyprowadzenie tego samego tekstu.

Jeśli chcesz, aby w makrze było wiele sekcji zmiennych, możesz użyć elementu #assign.

Przykład strony #macro umożliwiając zdefiniowanie zawartości ciała, nagłówek i stopka:

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

Następnie można określić każdą sekcję za pomocą elementu #assign (ale wprawdzie konieczności wielokrotnego nazwie #nested element będzie lepszy).

<#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> 

Wynikiem będzie:

This is the header. 
This is the nested content. 
This is the footer. 
Powiązane problemy