macros.vm
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#** -------------------------------------------
* 显示所有headers
* -------------------------------------------- *#
#macro (showHead $defaultTitle)
#showTitle ($defaultTitle)
#showMetaTags ()
#showHttpEquiv ()
#showStylesheets ()
#end
#** -------------------------------------------
* 显示js,
* -------------------------------------------- *#
#macro (showfoot $defaultTitle )
#showJavascripts ()
#end
#** -------------------------------------------
* 显示标题,如果未提供标题,则使用默认值
* -------------------------------------------- *#
#macro (showTitle $defaultTitle)
#if( $page.title != "" )
<title>$page.title</title>
#else
<title>$!defaultTitle</title>
#end
#end
#** -------------------------------------------
* 显示meta tags
* -------------------------------------------- *#
#macro (showMetaTags)
#foreach($metaTag in $page.metaTags.keySet())
<meta name="$metaTag" content="$page.metaTags.get($metaTag)">
#end
#end
#** -------------------------------------------
* 显示meta http-equiv
* -------------------------------------------- *#
#macro (showHttpEquiv)
#foreach($httpEquiv in $page.httpEquivs.keySet())
<meta http-equiv="$httpEquiv" content="$page.httpEquivs.get($httpEquiv)">
#end
#end
#** -------------------------------------------
* 显示stylesheets
* -------------------------------------------- *#
#macro (showStylesheets)
#foreach( $styleSheet in $page.styleSheets )
<link rel="stylesheet" href="$styleSheet.Url"
#if($styleSheet.Type != "" ) type="$styleSheet.Type" #end
#if($styleSheet.Media != "") media="$styleSheet.Media" #end
#if($styleSheet.Title != "") title="$styleSheet.Title" #end>
#end
#end
#** -------------------------------------------
* 显示javascripts
* -------------------------------------------- *#
#macro (showJavascripts)
#foreach( $script in $page.scripts )
<script type="text/javascript" src="$script" language="JavaScript"></script>
#end
#end
#** -------------------------------------------
* 显示body attributes
* -------------------------------------------- *#
#macro (bodyAttributes)
#foreach( $attributeName in $page.bodyAttributes.keySet() )
$attributeName="$page.bodyAttributes.get($attributeName)"
#end
#end
#** -------------------------------------------
* 显示select box
* -------------------------------------------- *#
#macro (select $name $map $selected $hint)
#set ($_map = $map)
#set ($_selected = $selected)
<select name="$name">
<option value="">$hint</option>
#foreach ($_key in $_map.keySet())
<option value="$_key" #if ($_key == $_selected) selected #end>$_map.get($_key)</option>
#end
</select>
#end