문서의 이전 판입니다!
General → Content Types
에서 HTML에 *.ftl
을 등록해주면 HTML 템플릿 엔진으로 사용가능.??
null이 아닌지 테스트!“기본값”
: null일경우 기본값으로 대체. “기본값”
을 생량하고 !
만 쓰면 빈 문자열, 빈 시퀀스, 빈 해시를 나타내게 된다.- null이 아닌가?(아니면 true) <#if aVariable??> - 문자열의 경우 null이거나, empty인가? <#if aVariable?has_content> 혹은 <#if aVariable!?size > 0 or aVariable!?length > 0> - Missing Value Operator. someValue가 존재하는가? <#if someValue??> ... - someValue와 someProp이 모두 존재해야 true <#if (someValue.somePrope)??>
!기본표현식
이 가능하다.!기본표현식
뒤에 다른 표현식이 오면 꼭 괄호로 감싸야한다.someValue!"기본값" - 아래 구문은 작동하지 않는다. "'기본값' == '다른값'"을 기본값 표현식으로 간주하기 때문. <#if someValue!'기본값' == '다른값'> -> 다음처럼 변경할 것 <#if (someValue!'기본값') == '다른값'> colors!['red', 'blue', 'green'] - someValue가 null이라도 자동으로 기본값으로 지정된다. (someValue.someProp)!'기본값'
<#macro showDealUnitTemplate deals deal?default.. idx>...</#macro> 혹은.. <#macro showDealUnitTemplate deals deal="" idx>...</#macro>
TemplateModel
로 변환된 모델에서 원래의 Java 객체를 빼내는 역할. 대부분의 ObjectWrapper는 이 인터페이스를 구현한다.cfg.setNumberFormat("0.######"); // now it will print 1000000