이 문서는 Atlassian에서 제공하는 Velocity Template 이용 방법을 공유하기 위해 작성되었다.
| 도구명 | Velocity Template/HTML |
|---|
Servlet에서 vm File로 데이터 전송
Java Servlet
@ComponentImport
private final IssueManager issueManager;
private final TemplateRenderer templateRenderer;
public Map<String, Object> map = new HashMap<>();
public Map<String, Object> totalMap = new HashMap<>();
List<Issue> issueList = issueManager.getIssueObjects(Collection<IssueIds> collection);
map.put("issues", issueList);
totalMap.put("map", map);
templateRenderer.render("/templates/my-vm.vm", totalMap, response.getWriter());
- API를 이용해 가져온 Issue를 map에 저장
- templateRenderer api 이용, vm으로 Issue data 전송
Velocity Template로 이슈 정보 출력
#foreach($map in $totalMap.get("map"))
<td>$map.summary</td>
<td>$map.assigneeUser.name</td>
<td>$map.creator.name</td>
<td>$map.created</td>
<td>!$map.updated</td> <!-- !$ : map의 update값이 없을 때 빈 값 출력 -->
#end
#set($h = "world")
Hello $h
#if ($ref == $null,false,'',0....) <!-- null 값을 구체적으로 테스트 -->
- #foreach 이용, 반복문으로 issue 정보 출력
Velocity Template Examples
예제
#foreach($map in $totalMap.get("map"))
<td>!$map.updated</td> <!-- !$ : map의 update값이 없을 때 빈 값 출력 -->
#end
#set($h = "world")
Hello $h
#if ($ref == $null,false,'',0....) <!-- null 값을 구체적으로 테스트 -->
#if( $num < 10 )
**do something**
#elseif( $num == 10 )
**do something**
#elseif( $num == 6 )
**do something**
#else
**do something**
#end
#if( $foo == $bar)it's true!#{else}it's not!#end
#macro( d )
<tr><td></td></tr>
#end
- velocity template examples
참조
내용