<%=input%>
<%=json%>
hello,@@{user.name}@@
var user={name:'beetl',age:2};
@_var name='beetl',age=2;_@
@@{name}@@
@_
var name='beetl',age=2, msg = "hello "+name+" age is "+age ;
_@
@@{msg}@@
@_
for(user in userList){
_@
@@{user.name}@@
@_}_@
var userList=[{name:'lijz',age:18},{name:'lucy',age:16}];
@_
if(name=='lijzh'||age!=18){
_@
Hello,@@{name}@@
@_}else{_@
Morning @@{name}@@
@_}_@
var name='lijz';
var age= 18;
@@{user.name!'未知'}@@
var user = null;
@_
var list = [5,2,4];
_@
@@{ @java.util.Collections.max(list)}@@
@_
var date = date();
_@
today is @@{ date}@@
@_
var date = date();
_@
today is @@{date,dateFormat='yyyy-MM-dd'}@@
size is @@{userList.~size}@@
var userList=[{name:'lijz',age:18},{name:'lucy',age:16}];
@_
var number = 1 ;
var str = "hello";
var now = date();
var isChecked = true;
var nullValue = null;
_@
number is @@{number}@@,str is @@{str}@@,time is @@{now}@@
@@{isChecked}@@
nullValue=@@{nullValue}@@.
@_
var number = 1 ,str="hello",now = date();
_@
number is @@{number}@@,str is @@{str}@@,time is @@{now}@@
@_
var map={name:'joel',age:18};
var list=['open','close'];
_@
@@{map['name']}@@ = @@{map.name}@@
@@{list[0]}@@
@_
var bigNumber = 7777777777777.23;
var templateVar = {
_@
big number is @@{bigNumber}@@
@_};_@
现在输出模板变量:
@@{templateVar}@@
推荐: @@{user.wife.name}@@
不推荐:@@{user.wife["name"]}@@
var user = {name:'lijz',wife:{name:'lucy',age:17}};
@@{status[0]}@@
@@{status.~size}@@
var status = [1,2,3];
@@{status[0]}@@
var status = [1,2,3];
推荐 @@{map["key1"]}@@
不推荐 @@{map.key2}@@
var map = {key1:'value1',key2:'value2'} ;
@_
var a1 = 12;
var b1 = (a1+15)/3-2*a1;
var bc = -1-b1;
_@
@@{bc}@@
@_
var a1 = 12;
var b1 = a1==12;
var b2 = a1!=12;
_@
@@{b1}@@
@@{b2}@@
@_
var a1 = "joeli";
var b1 = a1=="joelli";
_@
@@{b1}@@
@_
var a=1;
var b = a==1?"hi":"hey";
_@
@@{b}@@
@_
print("总共"+userList.~size+"
");
for(user in userList){
_@
@@{userLP.index}@@ @@{user.name}@@
@_}_@
var userList=[{name:'lijz',age:18},{name:'lucy',age:16}];
@_
print("总共"+map.~size+"
");
for(user in map){
_@
@@{userLP.index}@@ @@{user.key}@@ @@{user.value.name}@@
@_}_@
var map={"001":{name:'lijz'},"002":{name:'lucy'}};
@_
for(user in list!){
_@
@@{user}@@
@_}_@
end
var list=null;
@_
for(user in userList){
if(user.age==18){
print("it's lijz'");
continue;
}else if(user.age==16){
print("It's lucy");
break;
}else{
print("return ");
return ;
}
}
print("end loop");
_@
var userList=[{name:'lijz',age:18},{name:'lucy',age:16}];
@_
for(user in userList){
print(user.name);
}elsefor {
print("no data");
}
_@
var userList=[];
@_
// 设置过大循环,在线模板引擎将阻止
for(var i=0;i<5;i++){
print(i);
}
_@
@_
var user = map["001"];
if(user.name=="lijz"){
print(user.name);
}else{
return ;
}
_@
var map={"001":{name:'lijz'},"002":{name:'lucy'}};
@_
var status = "1";
switch(status){
case "0":{
print("0");
break ;
}
case "1":{
print("1");
break;
}
default:{
print("default");
}
}
_@
@@{nvl(user,"Beetl")}@@
var user = null;
@@{decode(age,1,"age is 1",2,"age is 2","默认值")}@@
var age = 1;
@_
var status = "1";
select(status){
case "0","1":
print("small");
case "2":
print("big");
default:
print("default");
}
select{
case status=="0",status=="1":
print("small");
case status=="2":
print("big");
default:
print("default");
}
_@
@_
print("hello");
println("hello");
printf("hello,%s,your age is %s","lijz",12+"");
_@
@_
var now = date();
var date = date("2013-1-1","yyyy-MM-dd");
_@
now=@@{now,dateFormat='yyyy年MM月dd日'}@@
date=@@{date,dateFormat='yyyy年MM月dd日'}@@
@_
print(exist("session")+" ");
print(exist("user")+" ");
_@
var user = null;
@_
debug("仅仅在后台打印,前台什么都没有");
_@
@_
//请指定你的缓存key
cache("key",60,false){
_@
date = @@{date(),dateFormat='yy-MM-dd hh:mm::ss'}@@
@_}_@
now = @@{date(),dateFormat='yy-MM-dd hh:mm::ss'}@@
@_
var now = date();
var date = date("2013-1-1","yyyy-MM-dd");
_@
now=@@{now,dateFormat='yyyy年MM月dd日'}@@
date=@@{date,dateFormat='yyyy年MM月dd日'}@@
or
now=@@{now,'yyyy年MM月dd日'}@@
@_
var number = 12.7893;
_@
number=@@{number,numberFormat='#.##'}@@
or
number=@@{number,'#.##'}@@
@_
var list = [5,2,4];
_@
@@{ @java.util.Collections.max(list)}@@
@@{ @java.util.logging.Level.INFO }@@
@@{ @list.isEmpty() }@@
var list = [];
@_
var list = [5,2,4]
var a =12;
_@
@_
var a =5/0;
_@
@@{user1.wife.name!"单身"}@@
@@{user2.wife.name!}@@
@@{user3.wife.name!"单身"}@@
var user1 = null;
var user2 = null;
var user3 = {"name":"lijz",wife:{'name':'lucy'}};
@_ DIRECTIVE SAFE_OUTPUT_OPEN ;_@
@@{user1.wife.name}@@
@@{user2.wife.name}@@
@@{user3.wife.name}@@
@_ DIRECTIVE SAFE_OUTPUT_CLOSE ;_@
var user1 = null;
var user2 = null;
var user3 = {"name":"lijz",wife:{'name':'lucy'}};
@@{str1!''==''}@@
@@{str2!''==''}@@
@@{str3!''==''}@@
@@{str4!''==''}@@
var str1 = null;
var str2 = '';
//var str3='input' ,不定义str3
var str4 = 'input';
@@{isEmpty(str1)}@@
@@{isEmpty(str2)}@@
@@{isEmpty(str3)}@@
@@{isEmpty(str4)}@@
@@{isEmpty(str5)}@@
var str1 = null;
var str2 = '';
//var str3='input' ,不定义str3
var str4 = 'input';
var str5 = [];
@_
//最大值是12;
var max = 12;
_@
@_
/*
var max = 12;
*/
_@
@_
//类似java的泛型,可以用在任何有var的地方,比如var<List<User>> userList =getUsers()
var<Integer> max = 12;
_@
${max}
@_
for(var<String> i in list){
println(i);
}
_@
var list = ["a","b"];