Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

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 }}
```