Skip to content

Commit 03d4c67

Browse files
authored
Merge pull request #27 from hazendaz/master
Use velocity to display proper version on site documentation
2 parents f19e7af + f7ecb74 commit 03d4c67

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/site/xdoc/index.xml renamed to src/site/xdoc/index.xml.vm

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2015-2016 the original author or authors.
4+
Copyright 2015-2017 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
1616
limitations under the License.
1717
1818
-->
19+
#set( $D = '$' )
20+
#set( $N = '#if' )
1921
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2022
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
2123
<properties>
@@ -54,7 +56,7 @@
5456
<dependency>
5557
<groupId>org.mybatis.scripting</groupId>
5658
<artifactId>mybatis-freemarker</artifactId>
57-
<version>1.1</version>
59+
<version>${project.version}</version>
5860
</dependency>
5961
</dependencies>]]></source>
6062

@@ -66,7 +68,7 @@ repositories {
6668
}
6769
6870
dependencies {
69-
compile("org.mybatis.scripting:mybatis-freemarker:1.1")
71+
compile("org.mybatis.scripting:mybatis-freemarker:${project.version}")
7072
}]]></source>
7173

7274
</section>
@@ -80,7 +82,7 @@ dependencies {
8082
<dependency>
8183
<groupId>org.mybatis.scripting</groupId>
8284
<artifactId>mybatis-freemarker</artifactId>
83-
<version>1.2-SNAPSHOT</version>
85+
<version>${project.version}</version>
8486
</dependency>]]></source>
8587
</li>
8688
</ul>
@@ -126,7 +128,7 @@ dependencies {
126128
<p>Just write your queries using FreeMarker syntax:</p>
127129
<source><![CDATA[
128130
@Lang(FreeMarkerLanguageDriver.class)
129-
@Select("select * from names where id in (${ids?join(',')})")
131+
@Select("select * from names where id in (${D}{ids?join(',')})")
130132
List<Name> findNamesByIds(@Param("ids") List<Integer> ids);]]></source>
131133
<p>If any whitespace found inside <code>@Select</code> text, it is interpreted as inline script, not template name. It is convenient to avoid creating templates when script is really small. If you have a large SQL script, you can place it in distinct template and write next code:</p>
132134
<source><![CDATA[
@@ -143,8 +145,8 @@ where firstName = <@p name="n"/>]]></source>
143145
This markup further will be passed into MyBatis engine, and it will replace this to <code>?</code>-parameter.
144146
You can't write <code>#{paramName}</code> directly, because FreeMarker supports this syntax natively
145147
(alghough it is deprecated). So, to get <code>?</code>-parameters to prepared statements works, you need
146-
to use <code>${r"#{paramName}"}</code> verbose syntax, or this directive. By the way, in XML
147-
files <code>${r"#{paramName}"}</code> is more preferrable because you don't need wrap it using
148+
to use <code>${D}{r"#{paramName}"}</code> verbose syntax, or this directive. By the way, in XML
149+
files <code>${D}{r"#{paramName}"}</code> is more preferrable because you don't need wrap it using
148150
<code>CDATA</code> statements. In annotations and in external templates <code>&lt;@p/&gt;</code>
149151
directive is more neat.</p>
150152
</section>
@@ -153,20 +155,20 @@ where firstName = <@p name="n"/>]]></source>
153155
<p>As in annotations, you can write inline scripts or template names.</p>
154156
<source><![CDATA[
155157
<!-- This is handled by FreeMarker too, because it is included into select nodes AS IS -->
156-
<sql id="cols">id, ${r"firstName"}, lastName</sql>
158+
<sql id="cols">id, ${D}{r"firstName"}, lastName</sql>
157159
158160
<select id="findName" resultType="org.mybatis.scripting.freemarker.Name" lang="freemarker">
159161
findName.ftl
160162
</select>
161163
162164
<select id="findNamesByIds" resultType="org.mybatis.scripting.freemarker.Name" lang="freemarker">
163-
select <include refid="cols"/> from names where id in (${ids?join(',')})
165+
select <include refid="cols"/> from names where id in (${D}{ids?join(',')})
164166
</select>
165167
166168
<!-- It is not very convenient - to use CDATA blocks. Better is to create external template
167-
or use more verbose syntax: ${r"#{id}"}. -->
169+
or use more verbose syntax: ${D}{r"#{id}"}. -->
168170
<select id="find" resultType="org.mybatis.scripting.freemarker.Name" lang="freemarker">
169-
select * from names where id = <![CDATA[ <@p name='id'/>]]>]]&gt;<![CDATA[ and id = ${id}
171+
select * from names where id = <![CDATA[ <@p name='id'/>]]>]]&gt;<![CDATA[ and id = ${D}{id}
170172
</select>]]></source>
171173
</section>
172174

@@ -185,7 +187,7 @@ where firstName = <@p name="n"/>]]></source>
185187
select * from names where firstName in (
186188
<#list ids as id>
187189
<@p value=id/>
188-
<#if id_has_next>,</#if>
190+
<${N} id_has_next>,</${N}>
189191
</#list>
190192
)]]></source>
191193
This markup will be translated to

0 commit comments

Comments
 (0)