我自己项目里用的beetl示例

使用传统的<%%>作为定界符。占位符也是用传统的${}

变量imageServer通过native call获取,目前1.24不支持navtive chain call。1.25即将支持

定义了一个javascript变量ctxPath,这样,可以在随后的js文件中采用

 自从写了beetl后,很少有自己能决定技术选型的项目,现在终于有来了一个,我毫不犹豫用上心爱的beetl作为模板技术

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
    content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no">
<link rel="stylesheet" href="${ctxPath}/mobile/codebase/touchui.css" type="text/css"
    media="screen" charset="utf-8">
<link rel="stylesheet" href="${ctxPath}/mobile/style.css" type="text/css"
    media="screen" charset="utf-8">

<script src="${ctxPath}/mobile/codebase/touchui_debug.js" type="text/javascript" charset="utf-8"></script>
<script src="${ctxPath}/mobile/codebase/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<%
var config = @com.zps.baby.util.Config.instance();
var imageServer = @config.get("image_web_url");
%>
<script>

var ctxPath = "${ctxPath}";
var phone = "${@com.zps.baby.util.MobileUtil.getPhone(servlet.request)}";
var imageServer = "${imageServer}";
	  /*根据文件名得到图片大小*/
    function getSize(file){
    	var all = file.split("-");
    	//最后俩个是宽高
    	var s1 = all[all.length-1];
    	var s2 = all[all.length-2];
    	var imgWidth = parseInt(s2);
    	var index = s1.indexOf('.');
    	var imgHeight = parseInt(s1.substring(0,index));
    	return {width:imgWidth,height:imgHeight}    	
    }
</script>

</head>
<body >

${layoutContent}

</body>
</html>

你可能感兴趣的:(beetl)