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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
# Syntax
## Indent
A unit of an indent must be 2 spaces.
```ace
html
body
div
p
```
becomes
```html
<html>
<body>
<div></div>
<p></p>
</body>
</html>
```
## HTML Tags
A head word of a line is interpreted as an HTML tag. The rest words of the same line are interpreted as attributes or a text. An attribute value which contains spaces must be surrounded by double quotes. An attribute without value (like "check" and "required") can be defined by specifying no value and ending with an equal (=).
```ace
div id=container style="font-size: 12px; color: blue;"
p class=row This is interpreted as a text.
a href=https://github.com/ Go to GitHub
input type=checkbox checked=
```
becomes
```html
<div id="container" style="font-size: 12px; color: blue;">
<p class="row">This is interpreted as a text.</p>
<a href="https://github.com/">Go to GitHub</a>
<input type="checkbox" checked>
</div>
```
ID and classes can be defined with a head word of a line.
```ace
p#foo.bar
#container
.wrapper
```
becomes
```html
<p id="foo" class="bar"></p>
<div id="container"></div>
<div class="wrapper"></div>
```
Block texts can be defined as a child element of an HTML tag by appending a dot (.) or double dot (..) to the head word of a line. BR tags are inserted to each line except for the last line by appending a double dot (..) to the head word of a line.
```ace
script.
var msg = 'Hello Ace';
alert(msg);
p..
This is a block text.
BR tags are inserted
automatically.
```
becomes
```html
<script>
var msg = 'Hello Ace';
alert(msg);
</script>
<p>
This is a block text.<br>
BR tags are inserted<br>
automatically.
</p>
```
## Plain Texts
A line which starts with a pipe (|) or double pipe (||) is interpreted as a block of plain texts. BR tags are inserted to each line except for the last line by having a line start with a double pipe (||).
```ace
div
| This is a single line.
div
|
This is a
block line.
div
||
This is a
block line
with BR tags.
```
becomes
```html
<div>
This is a single line.
</div>
<div>
This is a
block line.
</div>
<div>
This is a<br>
block line<br>
with BR tags.
</div>
```
## Helper Methods
A line which starts withs an equal (=) is interpreted as a helper method.
```ace
= helperMethodName
```
The following helper methods are available.
### Conditional Comment Helper Method
A conditional comment helper method generates a [conditional comment](http://en.wikipedia.org/wiki/Conditional_comment).
```ace
= conditionalComment commentType condition
```
The following comment types are acceptable:
| Comment Type | Generated HTML |
| ------------ |----------------------------------------|
| hidden | <!--[if expression]> HTML <![endif]--> |
| revealed | <![if expression]> HTML <![endif]> |
```ace
= conditionalComment hidden IE 6
<p>You are using Internet Explorer 6.</p>
= conditionalComment revealed !IE
<link href="non-ie.css" rel="stylesheet">
```
becomes
```html
<!--[if IE 6]>
<p>You are using Internet Explorer 6.</p>
<![endif]-->
<![if !IE]>
<link href="non-ie.css" rel="stylesheet">
<![endif]>
```
### Content Helper Method
A content helper method defines a block content which is embedded in the base template. This helper method must be used only in the inner template.
```
= content main
h2 Inner Template - Main : {{.Msg}}
= content sub
h3 Inner Template - Sub : {{.Msg}}
```
### CSS Helper Method
A css helper method generates a style tag which has "text/css" type.
```ace
= css
body {
margin: 0;
}
h1 {
font-size: 200%;
color: blue;
}
```
becomes
```html
<style type="text/css">
body {
margin: 0;
}
h1 {
font-size: 200%;
color: blue;
}
</style>
```
### Doctype Helper Method
A doctype helper method generates a doctype tag.
```ace
= doctype doctypeName
```
The following doctype names are acceptable:
| Doctype Name | Generated HTML |
| ------------ |--------------------------------------|
| html | <!DOCTYPE html> |
| xml | <?xml version="1.0" encoding="utf-8" ?> |
| transitional | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| strict | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| frameset | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> |
| 1.1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| basic | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> |
| mobile | <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"> |
```ace
= doctype html
```
becomes
```html
<!DOCTYPE html>
```
### Include Helper Method
An include helper method includes another template. You can pass a pipeline (parameter) from the including template to the included template.
```ace
= include templatePathWithoutExtension pipeline
```
### Javascript Helper Method
A javascript helper method generates a script tag which has "text/javascript" type.
```ace
= javascript
var msg = 'Hello Ace';
alert(msg);
```
becomes
```html
<script type="text/javascript">
var msg = 'Hello Ace';
alert(msg);
</script>
```
### Yield Helper Method
A yield helper method generates the HTML tags which are defined in the inner template. This helper method must be used only in the base template.
```
= yield main
| This message is rendered if the "main" content is not defined in the inner template.
= yield sub
| This message is rendered if the "sub" content is not defined in the inner template.
```
## Comments
A line which starts with a slash (/) or double slash (//) is interpreted as a comment. A line which starts with a slash (/) is not rendered. A line which starts with a double slash (//) is renderd as an HTML comment.
```ace
/ This is a single line comment which is not rendered.
/
This is a multiple lines comment
which is not rendered.
// This is a single line comment which is rendered as an HTML comment.
//
This is a multiple lines comment
which is rendered as an HTML comment.
```
becomes
```html
<!-- This is a single line comment which is rendered as an HTML comment. -->
<!--
This is a multiple lines comment
which is rendered as an HTML comment.
-->
```
## Actions
[Actions](http://golang.org/pkg/text/template/#hdr-Actions) of the template package can be embedded in Ace templates.
```ace
body
h1 Base Template : {{.Msg}}
{{if true}}
p Conditional block
{{end}}
```
The following functions are predefined.
### HTML function
HTML function returns a non-escaped string.
```ace
{{"<br>"}}
{{HTML "<br>"}}
```
becomes
```html
<br>
<br>
```
|