Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iglazunoff/govite
Adapter for go templates and VITE.JS
https://github.com/iglazunoff/govite
Last synced: about 1 month ago
JSON representation
Adapter for go templates and VITE.JS
- Host: GitHub
- URL: https://github.com/iglazunoff/govite
- Owner: iglazunoff
- License: mit
- Created: 2024-03-03T18:50:51.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-03-04T08:56:45.000Z (10 months ago)
- Last Synced: 2024-06-21T14:22:21.357Z (7 months ago)
- Language: Go
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-vite-js
Slim adapter for GO templates and VITE.JS
---
## Example:
### Initialization in application
Create vite.js adapter & define adapter like payload for template, for example in GIN handler:
```go
func main() {
// creating new adapter
govite := govite.Default()// define payload for route
payload := &gin.H{
"vite": vitejs,
}// create http router
router := gin.Default()
// define templates
router.LoadHTMLGlob("templates/*")
// define route
router.GET("/", func(context *gin.Context) {
context.HTML(200, "website", c.payload)
})// run http server
router.Run(":8080")
}
```### Using in GO templates
Create addition template for inject it to footer:
```html
{{ define "vite.footer" }}
{{ if ne .vite.IsProduction true }}
{{ end }}
{{ end }}
```Define template for some page
```html
{{ define "website" }}
go-vite-js
Go with Vite.js
{{ template "vite.footer" . }}
{{ end }}
```