Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 7 days ago
JSON representation
Utilities for working with text/template or html/template source.
- Host: GitHub
- URL: https://github.com/crhntr/template
- Owner: crhntr
- License: mit
- Created: 2024-07-19T08:28:21.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-02T02:14:33.000Z (4 months ago)
- Last Synced: 2024-08-03T03:55:40.219Z (3 months ago)
- Topics: go, parsing, template, type-checking
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.gohtmlthe function `templatetest.AssertTypeCommentsAreFound` will ensure package and identifier in the `{{- /* gotype: ... */ -}}` comment are found.
```go
package hypertext_testimport (
"testing""github.com/crhntr/template/templatetest"
)func TestSource(t *testing.T) {
templatetest.AssertTypeCommentsAreFound(t, "", "", "*.gohtml")
}
``````go
package hypertexttype Website struct {
Name string
}
``````
{{- define "with no space after colon" -}}
{{- /* gotype: example.com/hypertext.Website */ -}}
{{- .Name -}}
{{- end -}}
```