2012-10-29 43 views

उत्तर

17

आपके पास अलग-अलग #nested मैक्रो में तत्व नहीं हो सकते हैं, इसके प्रत्येक उपयोग एक ही पाठ को आउटपुट करेगा।

यदि आप अपने मैक्रो में एकाधिक चर खंडों का लक्ष्य रखते हैं, तो आप #assign तत्व का उपयोग कर सकते हैं।

एक पेज के

उदाहरण #macro शरीर, शीर्ष लेख और पाद सामग्री परिभाषित करने की अनुमति:

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

फिर आप #assign तत्व का उपयोग प्रत्येक अनुभाग परिभाषित कर सकते हैं (लेकिन बेशक कई नामित होने #nested तत्व बेहतर होगा)।

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

जिसके परिणामस्वरूप उत्पादन होगा:

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

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^