Closed yansigit closed 4 years ago
Hello @yansigit, indeed pug
engine has an issue on its .Binary
. This is a very good and well-written bug report, expect a fix very soon.
The issue is found at: https://github.com/Joker/jade/blob/d475f43051e722977ea1bfa344e52b1bafd832ba/jade_parse.go#L442-L454 which is called on pug include & extends
directives and forces to read from directory even if we give the whole directory/contents, it's a bad design by its author because its Parse(name, contents)
should not be depended on the filesystem at all. I think I have to deep in its parser itself, clone the repository, push a PR there and add a replace
on our go.mod file for the jade/pug engine until the author accept the PR...
It's fixed on master branch, you can test it out by go get -u github.com/kataras/iris/v12@master
.
More improvements :
extends
templates - this is fixed tooextends layout.pug
instead of the full path extends templates/layout.pug
- makes template contents not relative to the root folder of the templatesIt will be officially available on the next minor version, v12.1.8
. I have to implement a new feature request before pushing the release (I am close to it too).
Again, thanks for the report.
Thank you for super fast update @kataras! I wish i could solve the problem, but another error is popping up if i compile and execute binary with master branch.
user@Home:~/Codes$ ./linux_x64
title_1
[ERRO] 2020/02/15 19:45 template:1: in '/home/user/Codes' subtemplate 'layout.pug': parseSubFile() error: template:4: open header.pug: no such file or directory work dir: /home/user/Codes for name 'delete.pug'
user@Home:~/Codes$ ./linux_x64
title_1
[ERRO] 2020/02/15 20:10 template:1: in '/home/user/Codes' subtemplate 'layout.pug': parseSubFile() error: template:4: open header.pug: no such file or directory work dir: /home/user/Codes for name 'index.pug'
user@Home:~/Codes$ ./linux_x64
title_1
[ERRO] 2020/02/15 20:10 template:1: in '/home/user/Codes' subtemplate 'layout.pug': parseSubFile() error: template:4: open header.pug: no such file or directory work dir: /home/user/Codes for name 'index.pug'
user@Home:~/Codes$ ./linux_x64
title_1
[ERRO] 2020/02/15 20:10 template:1: in '/home/user/Codes' subtemplate 'layout.pug': parseSubFile() error: template:4: open header.pug: no such file or directory work dir: /home/user/Codes for name 'edit.pug'
user@Home:~/Codes$
go.mod
module frescawiki
go 1.13
require (
github.com/Kamva/mgm v1.2.1
github.com/kataras/iris/v12 v12.1.8-0.20200214213456-387c90b350d5
github.com/klauspost/compress v1.10.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/yuin/goldmark v1.1.22
go.mongodb.org/mongo-driver v1.3.0
golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 // indirect
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
gopkg.in/ini.v1 v1.52.0 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
gopkg.in/yaml.v3 v3.0.0-20200121175148-a6ecf24a6d71 // indirect
)
build scripts
go-bindata ./assets/... ./templates/...
go build
Another difference is that the app cannot recognize template files even if it has template folder on same directory now. Again, full source can be found at Here
Hmm @yansigit this works here, I tested it without the templates and with the templates folder yesterday. Let me check it again.
OK @yansigit, it was a minor addition... it really hurts my eyes (the code of jade go parser) but we support it so I fixed it, please test it and sorry for spent your time with this one.
Thank you @kataras, working like a charm after updating framework 😊 I'll try to debug myself and submit a PR next time. Thanks for your effort again!
No worries, but yes debugging is the best way to learn the framework too :) Just pushed the v12.1.8
release which brings support for grpc-compatible controllers too! go get -u github.com/kataras/iris/v12@latest
Output when running the app
Go source
Building scripts
Folder structure
bindata.go
All template files are imported in bindata.go well, and imported them on main source using
Binary(Asset, AssetNames)
too, but it's not working... Pug files are all associated as expected with codes like include, block Full source can be found in my repositoryIt's working if templates folder is on same location with compiled binary file, but what i want is embedding all static files to binary file.
I am not sure whether it's because of my mistake or bug, so I'll let it be as a question.