Significant Whitespace

Haml and Slim templates are significant whitespace languages. This means that the indentation of the content is important. EGO templates use normal HTML structure inside the template body.

Content that needs to be nested within an element is indented under that element.

Indentation

Indentation is used to indicate the structure of the content. The indentation creates the parent-child relationship of the elements.

GoHT Haml and Slim template content must be indented with at least one tab.

@haml MyTemplate() {
	%html
		%head
			%title= "Hello, World!"
		%body
			%h1= "Hello, World!"
}

renders as:

<html>
	<head>
		<title>Hello, World!</title>
	</head>
	<body>
		<h1>Hello, World!</h1>
	</body>
</html>

First line

The first line in a template must start at column one. After the first line, the indentation size and character are determined by the first significant whitespace before any content.

@haml MyTemplate() {
	%p
		%span Hello, World!
}

Tabs only

GoHT aligns with the gofmt tool coding style and uses tabs for Haml and Slim indentation.

Nesting

You may only indent children one level below their parent. You may unindent as many levels as you need.

@haml MyTemplate() {
	.main
		.header
			%h1
				Hello World!
		.content
			%p
				This is a paragraph.
	.footer
		%p
			This is a footer.
}

In the above, each new indent was only one level deeper than the previous. The .header and .content are children of .main. We return from several indents to put the .footer at the same level as .main.