Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/crhntr/template

Utilities for working with text/template or html/template source.
https://github.com/crhntr/template

go parsing template type-checking

Last synced: about 1 month ago
JSON representation

Utilities for working with text/template or html/template source.

Awesome Lists containing this project

README

        

# Template [![Go Reference](https://pkg.go.dev/badge/github.com/crhntr/template.svg)](https://pkg.go.dev/github.com/crhntr/template)

## "github.com/crhntr/template/templatetext"
Given the following three files in the package "hypertext" in the module "example.com":
- template_test.go
- template.go
- templates.gohtml

the function `templatetest.AssertTypeCommentsAreFound` will ensure package and identifier in the `{{- /* gotype: ... */ -}}` comment are found.

```go
package hypertext_test

import (
"testing"

"github.com/crhntr/template/templatetest"
)

func TestSource(t *testing.T) {
templatetest.AssertTypeCommentsAreFound(t, "", "", "*.gohtml")
}
```

```go
package hypertext

type Website struct {
Name string
}
```

```
{{- define "with no space after colon" -}}
{{- /* gotype: example.com/hypertext.Website */ -}}

{{- .Name -}}

{{- end -}}
```