Class MyBatisParamDirective

java.lang.Object
org.mybatis.scripting.freemarker.MyBatisParamDirective
All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

public class MyBatisParamDirective extends Object implements freemarker.template.TemplateDirectiveModel
Custom FreeMarker directive for generating "#{paramName}" declarations in convenient way. Problem is FreeMarker supports this syntax natively and there are no chance to disable this (although it is deprecated). And to get "#{paramName}" we should write ${r"#{paramName}"}. With this directive you can write more simple:

     <@p name="paramName"/>
 

Also directive supports `value` attribute. If it is specified, param will take passed value and create the corresponding #{}-parameter. This is useful in loops:

     <#list ids as id>
       <@p value=id/>
       <#if id_has_next>,</#if>
     </#list>
 

will be translated into

     #{_p0},#{_p1},#{_p2}
 

And MyBatis engine will convert it to `?`-params finally.

Author:
elwood