Comments (1)
If you've a file layout with like, ui/index.html and ui/whatever.html, you can do this:
//go:embed ui/*
var ui embed.FS
func embeddedFH(config goview.Config, tmpl string) (string, error) {
path := filepath.Join(config.Root, tmpl)
bytes, err := ui.ReadFile(path + config.Extension)
return string(bytes), err
}
func main() {
//new template engine
gv := ginview.New(
goview.Config{
Root: "ui",
Extension: ".html",
},
)
gv.ViewEngine.SetFileHandler(embeddedFH)
router.HTMLRender = gv
}
And it'll render from your embedded assets.
from goview.
Related Issues (20)
- How to parse html template in to echo render? HOT 3
- Could you tell me the difference between include tag and template tag? HOT 5
- How to return html directly? HOT 2
- Question about how to call a function HOT 5
- Context pre-processors HOT 4
- How Can I Manual clear page cache? HOT 3
- go get error HOT 2
- gin how to embed the templates in binary? HOT 1
- docs: Example for range/each
- docs: Example for if/else HOT 1
- extends syntax
- 建议把_example包中代码单独做一个项目,作为依赖包提供,尽量保持项目依赖最少化。
- Need text/template support
- What file structure should I create to minimize duplication of html code? HOT 2
- why not support a method to dynamic clear cache ?
- How about partial support with `_` prefix?
- 我想要从子页面向 master 中定义的 menu 传值应该如何处理? HOT 2
- Minify Output HTML HOT 1
- Switching between rendering with the parent layout or not by adding .HTML to template name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goview.