Significant Whitespace

GoHT templates and Haml are significant whitespace languages. This means that the indentation of the content is important.

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 templates must be indented with at least one tab.

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

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

Tabs only

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

Nesting

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

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