unrolled / render

Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
MIT License
1.94k stars 146 forks source link

Render templates from `embed.FS` #88

Closed dominik-lekse closed 3 years ago

dominik-lekse commented 3 years ago

Render templates from an embedded filesystem provides as an embed.FS.

Description

Proposed changes

Example usage

// ...

//go:embed templates/*.html templates/*.tmpl
var embeddedTemplates embed.FS

// ...

r := render.New(render.Options{
    Directory: "templates",
    FileSystem: &EmbedFileSystem{
        FS: embeddedTemplates,
    },
    Extensions: []string{".html", ".tmpl"},
})
// ...

References