htmgo/htmgo-site/pages/snippets/data.go

25 lines
488 B
Go
Raw Normal View History

2024-10-28 15:32:50 +00:00
package snippets
import "github.com/maddalax/htmgo/framework/h"
type Snippet struct {
2024-10-28 15:56:03 +00:00
name string
description string
sidebarName string
path string
partial h.PartialFunc
externalRoute string
sourceCodePath string
2024-10-28 15:32:50 +00:00
}
func SetSnippet(ctx *h.RequestContext, snippet *Snippet) {
ctx.Set("snippet", snippet)
}
func GetSnippet(ctx *h.RequestContext) *Snippet {
if ctx.Get("snippet") == nil {
return nil
}
return ctx.Get("snippet").(*Snippet)
}