Skip to content

Commit a518f8f

Browse files
committed
prep for v0.6.3
1 parent ca4f761 commit a518f8f

File tree

2 files changed

+62
-52
lines changed

2 files changed

+62
-52
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=v0.6.2
1+
VERSION=v0.6.3

README.md

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ A [Haml](http://haml.info/) and [Slim](https://slim-template.github.io/) templat
55

66
[![Go Report Card](https://goreportcard.com/badge/github.com/stackus/goht)](https://goreportcard.com/report/github.com/stackus/goht)
77
[![](https://godoc.org/github.com/stackus/goht?status.svg)](https://pkg.go.dev/github.com/stackus/goht)
8+
[![Coverage Status](https://coveralls.io/repos/github/stackus/goht/badge.svg?branch=main)](https://coveralls.io/github/stackus/goht?branch=main)
89

910
## Table of Contents
1011
- [Features](#features)
1112
- [Quick Start](#quick-start)
1213
- [Supported Haml Syntax & Features](#supported-haml-syntax--features)
1314
- [Unsupported Haml Features](#unsupported-haml-features)
1415
- [Supported Slim Syntax & Features](#supported-slim-syntax--features)
15-
- [Unsupported Slim Features](#unsupported-slim-features)
16+
- [Unsupported Slim Features](#unsupported-slim-features)
1617
- [GoHT CLI](#goht-cli)
1718
- [IDE Support](#ide-support)
18-
- [LSP](#lsp)
19+
- [LSP](#lsp)
1920
- [Library Installation](#library-installation)
2021
- [Using GoHT](#using-goht)
2122
- [Using GoHT with HTTP handlers](#using-goht-with-http-handlers)
@@ -79,20 +80,20 @@ Use the generated Go code to render HTML in your application:
7980
package main
8081

8182
import (
82-
"fmt"
83-
"log"
84-
"net/http"
83+
"fmt"
84+
"log"
85+
"net/http"
8586
)
8687

8788
func main() {
88-
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
89-
_ = HomePage().Render(r.Context(), w)
90-
})
91-
92-
fmt.Println("Server starting on port 8080...")
93-
if err := http.ListenAndServe(":8080", nil); err != nil {
94-
log.Fatal(err)
95-
}
89+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
90+
_ = HomePage().Render(r.Context(), w)
91+
})
92+
93+
fmt.Println("Server starting on port 8080...")
94+
if err := http.ListenAndServe(":8080", nil); err != nil {
95+
log.Fatal(err)
96+
}
9697
}
9798
```
9899
Which would serve the following HTML:
@@ -123,6 +124,7 @@ Which would serve the following HTML:
123124
- [x] Inlining Code (`- code`)
124125
- [x] Rendering Code (`= code`)
125126
- [x] Filters (`:plain`, ...) [(more info)](#filters)
127+
- [x] Long Statement wrapping (`\`), (`,`)]
126128
- [x] Whitespace Removal (`%tag>`, `%tag<`) [(more info)](#whitespace-removal)
127129

128130
### Unsupported Haml Features
@@ -217,19 +219,19 @@ This is what you'll use to render your templates in the application.
217219
package main
218220

219221
import (
220-
"context"
221-
"os"
222+
"context"
223+
"os"
222224

223-
"github.com/stackus/goht/examples/tags"
225+
"github.com/stackus/goht/examples/tags"
224226
)
225227

226228
func main() {
227-
tmpl := tags.RemoveWhitespace()
229+
tmpl := tags.RemoveWhitespace()
228230

229-
err := tmpl.Render(context.Background(), os.Stdout)
230-
if err != nil {
231-
panic(err)
232-
}
231+
err := tmpl.Render(context.Background(), os.Stdout)
232+
if err != nil {
233+
panic(err)
234+
}
233235
}
234236
```
235237
The above would render the `RemoveWhitespace` example from the [examples](/examples) directory in this repository,
@@ -250,22 +252,22 @@ Using the GoHT templates is made straightforward.
250252
package main
251253

252254
import (
253-
"fmt"
254-
"log"
255-
"net/http"
255+
"fmt"
256+
"log"
257+
"net/http"
256258

257-
"github.com/stackus/goht/examples/hello"
259+
"github.com/stackus/goht/examples/hello"
258260
)
259261

260262
func main() {
261-
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
262-
_ = hello.World().Render(r.Context(), w)
263-
})
264-
265-
fmt.Println("Server starting on port 8080...")
266-
if err := http.ListenAndServe(":8080", nil); err != nil {
267-
log.Fatal(err)
268-
}
263+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
264+
_ = hello.World().Render(r.Context(), w)
265+
})
266+
267+
fmt.Println("Server starting on port 8080...")
268+
if err := http.ListenAndServe(":8080", nil); err != nil {
269+
log.Fatal(err)
270+
}
269271
}
270272
```
271273

@@ -364,12 +366,12 @@ This also means that you can declare them with parameters and can use those para
364366
The same applies to Slim templates:
365367
```slim
366368
@slim SiteLayout(title string) {
367-
doctype html
368-
html(lang="en")
369-
head
370-
title= title
371-
body
372-
/ ... the rest of the template
369+
doctype html
370+
html(lang="en")
371+
head
372+
title= title
373+
body
374+
/ ... the rest of the template
373375
}
374376
```
375377

@@ -381,7 +383,7 @@ Only the HTML 5 doctype is supported, and is written using `!!!`.
381383
}
382384
383385
@slim SiteLayout() {
384-
doctype
386+
doctype
385387
}
386388
```
387389

@@ -432,7 +434,15 @@ You would write this with Go (Go needs the `!= nil` check):
432434
```
433435
There is minimal processing performed on the Go code you put into the templates, so it needs to be valid Go code sans braces.
434436

435-
> You may continue to use the braces if you wish. Existing code with braces will continue to work without modifications.
437+
Long statements can be split over by ending a line with either a backslash `\` or a comma `,`.
438+
439+
```haml
440+
- if user != nil && user.Name != ""\
441+
&& user.Age > 0
442+
%strong The user is not empty
443+
```
444+
445+
> You may continue to use the braces at the ends of your lines if you wish. Existing code with braces will continue to work without modifications.
436446
437447
### Rendering code
438448
Like in Haml, you can output variables and the results of expressions. The `=` script syntax and text interpolation `#{}` are supported for both template languages.
@@ -455,11 +465,11 @@ You would need to write this:
455465
```haml
456466
%strong= fmt.Sprintf("%d", user.Age)
457467
```
458-
Which to be honest can be a bit long to write, so a shortcut is provided:
468+
Which, to be honest, can be a bit long to write, so a shortcut is provided:
459469
```haml
460470
%strong=%d user.Age
461471
```
462-
The interpolation also supports the shortcut:
472+
The interpolation syntax also supports the shortcut:
463473
```haml
464474
%strong #{user.Name} is #{%d user.Age} years old.
465475
```
@@ -505,8 +515,8 @@ Keep in mind that attribute names cannot be replaced with an interpolated string
505515
To support dynamic lists of attributes, you can use the `@attributes` directive.
506516
This directive takes a list of arguments which comes in two forms:
507517
- `map[string]string`
508-
- The key is the attribute name, the value is the attribute value.
509-
- The attribute will be rendered if the value is not empty.
518+
- The key is the attribute name, the value is the attribute value.
519+
- The attribute will be rendered if the value is not empty.
510520
- `map[string]bool`
511521
- The key is the attribute name, the value is the condition to render the attribute.
512522
```haml
@@ -521,11 +531,11 @@ GoHT supports the `.` operator for classes and also will accept the `class` attr
521531
However, if the class attribute is given an interpolated value, it will need to be a comma separated list of values.
522532
These values can be the following types:
523533
- `string`
524-
- `myClass` variable or `"foo bar"` string literal
534+
- `myClass` variable or `"foo bar"` string literal
525535
- `[]string`
526-
- Each item will be added to the class list if it is not blank.
536+
- Each item will be added to the class list if it is not blank.
527537
- `map[string]bool`
528-
- The key is the class name, the value is the condition to include the class.
538+
- The key is the class name, the value is the condition to include the class.
529539

530540
Examples:
531541
```haml
@@ -558,9 +568,9 @@ GoHT supports inlining tags to keep templates as compact as possible.
558568

559569
```slim
560570
ul
561-
li: a.First Fist Item
562-
li: a.Second Second Item
563-
li: a.Third Third Item
571+
li: a.First Fist Item
572+
li: a.Second Second Item
573+
li: a.Third Third Item
564574
```
565575

566576
### Filters

0 commit comments

Comments
 (0)