stevenbooru/vendor/src/github.com/yosssi/ace/documentation/syntax.md

6.8 KiB

Syntax

Indent

A unit of an indent must be 2 spaces.

html
  body
    div
    p

becomes

<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 (=).

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

<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.

p#foo.bar
#container
.wrapper

becomes

<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.

script.
  var msg = 'Hello Ace';
  alert(msg);
p..
  This is a block text.
  BR tags are inserted
  automatically.

becomes

<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 (||).

div
  | This is a single line.
div
  |
    This is a
    block line.
div
  ||
    This is a
    block line
    with BR tags.

becomes

<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.

= helperMethodName

The following helper methods are available.

Conditional Comment Helper Method

A conditional comment helper method generates a conditional comment.

= conditionalComment commentType condition

The following comment types are acceptable:

Comment Type Generated HTML
hidden
revealed <![if expression]> HTML <![endif]>
= conditionalComment hidden IE 6
  <p>You are using Internet Explorer 6.</p>
= conditionalComment revealed !IE
  <link href="non-ie.css" rel="stylesheet">

becomes

<!--[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.

= css
  body {
    margin: 0;
  }
  h1 {
    font-size: 200%;
    color: blue;
  }

becomes

<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.

= doctype doctypeName

The following doctype names are acceptable:

Doctype Name Generated HTML
html
xml
transitional
strict
frameset
1.1
basic
mobile
= doctype html

becomes

<!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.

= include templatePathWithoutExtension pipeline

Javascript Helper Method

A javascript helper method generates a script tag which has "text/javascript" type.

= javascript
  var msg = 'Hello Ace';
  alert(msg);

becomes

<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.

/ 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

<!-- 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 of the template package can be embedded in Ace templates.

body
  h1 Base Template : {{.Msg}}
  {{if true}}
    p Conditional block
  {{end}}

The following functions are predefined.

HTML function

HTML function returns a non-escaped stirng.

{{"<div>"}}
{{HTML "<div>"}}

becomes

&lt;br&gt;
<br>