MCPcopy Create free account
hub / github.com/kataras/iris / Handlebars

Function Handlebars

view/handlebars.go:47–66  ·  view source on GitHub ↗

Handlebars creates and returns a new handlebars view engine. The given "extension" MUST begin with a dot. Usage: Handlebars("./views", ".html") or Handlebars(iris.Dir("./views"), ".html") or Handlebars(embed.FS, ".html") or Handlebars(AssetFile(), ".html") for embedded data.

(fs interface{}, extension string)

Source from the content-addressed store, hash-verified

45// Handlebars(iris.Dir("./views"), ".html") or
46// Handlebars(embed.FS, ".html") or Handlebars(AssetFile(), ".html") for embedded data.
47func Handlebars(fs interface{}, extension string) *HandlebarsEngine {
48 s := &HandlebarsEngine{
49 fs: getFS(fs),
50 rootDir: "/",
51 extension: extension,
52 templateCache: make(map[string]*raymond.Template),
53 funcs: make(template.FuncMap), // global
54 }
55
56 // register the render helper here
57 raymond.RegisterHelper("render", func(partial string, binding interface{}) raymond.SafeString {
58 contents, err := s.executeTemplateBuf(partial, binding)
59 if err != nil {
60 return raymond.SafeString("template with name: " + partial + " couldn't not be found.")
61 }
62 return raymond.SafeString(contents)
63 })
64
65 return s
66}
67
68// RootDir sets the directory to be used as a starting point
69// to load templates from the provided file system.

Callers

nothing calls this directly

Calls 2

executeTemplateBufMethod · 0.95
getFSFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…