[Freemarker] 사용자 정의 매크로에서 세미콜론은?




사용자 정의 매크로를 쓰려고 보니 세미콜론(;)이 나왔다. 쌩뚱맞게 나온 세미콜론... 어떤 용도로 쓰는지 알기 위해 freemarker 홈페이지에서 확인해보았다.








매크로를 사용할 때 파라미터 뒤에 세미콜론을 붙이고 변수나 상수를 콤마(,) 구분자로 설정하면, 매크로 내의 <#nested> 의 파라미터로 사용할 수 있다.






<#macro do_thrice>


<#nested 1>


<#nested 2>


<#nested 3>


</#macro>


<@do_thrice ; x> <#-- user-defined directive uses ";" instead of "as" -->


${x} Anything.


</@do_thrice>








<#macro repeat count>



<#list 1..count as x>



<#nested x, x/2, x==count>



</#list>



</#macro>



<@repeat count=4 ; c, halfc, last>



${c}. ${halfc}<#if last> Last!</#if>



</@repeat>







이렇게 쓰는 용도는 매크로 본문부가 반복이 되는 경우 해당 본문부에 파라미터를 매크로를 정의할 때 넘겨주게 설정할 때 사용하게 된다. (음;;;)






일단 이해했으니... 정리가 되면 고쳐야겠다.






참고자료:

http://freemarker.org/docs/dgui_misc_userdefdir.html









댓글

가장 많이 본 글