You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need the possible to render some data from a string to a varaible. But I wound like to reinitialize the complete View Engine with all the functions that need in both.
Would it be possible to make the Iris View Engine injectable like call direct ViewEngine functions or at last make if available the View Engine StringRenderer of each supporting Engine available.
The text was updated successfully, but these errors were encountered:
OK @Dexus I have implemented that on the HTML parser. Below you will find an example, if that's the expected behavior then I will do the same for the rest of the parsers too.
// Package main shows how to parse a template through custom byte slice content.package main
import"github.com/kataras/iris/v12"funcmain() {
app:=iris.New()
// To not load any templates from files or embedded data,// pass nil or empty string on the first argument:// view := iris.HTML(nil, ".html")view:=iris.HTML("./views", ".html")
view.ParseTemplate("program.html", []byte(`<h1>{{greet .Name}}</h1>`), iris.Map{
"greet": func(namestring) string {
return"Hello, "+name+"!"
},
})
app.RegisterView(view)
app.Get("/", index)
app.Get("/layout", layout)
app.Listen(":8080")
}
funcindex(ctx iris.Context) {
ctx.View("program.html", iris.Map{
"Name": "Gerasimos",
})
}
funclayout(ctx iris.Context) {
ctx.ViewLayout("layouts/main.html")
index(ctx)
}
./views/layout.html
<html><head><title>My Layout</title></head><body><h1>[layout] Body content is below...</h1><!-- Render the current template here -->
{{ yield }}
</body></html>
I need the possible to render some data from a string to a varaible. But I wound like to reinitialize the complete View Engine with all the functions that need in both.
Would it be possible to make the Iris View Engine injectable like call direct ViewEngine functions or at last make if available the View Engine StringRenderer of each supporting Engine available.
The text was updated successfully, but these errors were encountered: