sipin/gorazor

please provide a working "tpl" example for beginner

tjyang opened this issue · 4 comments

Here is the compilation error.
[tjyang@hp1 test]$ gorazor tpl tpl.out
Processing dir: tpl tpl.out
Processing: tpl/helper/footer.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/footer.go
Processing: tpl/helper/header.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/header.go
Processing: tpl/helper/msg.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/msg.go
Processing: tpl/home.gohtml --> /home/tjyang/gocode/src/test/tpl.out/home.go
Processing: tpl/layout/base.gohtml --> /home/tjyang/gocode/src/test/tpl.out/layout/base.go
[tjyang@hp1 test]$ cd tpl.out/
[tjyang@hp1 tpl.out]$ go build -x home.go
WORK=/tmp/go-build837451497
home.go:6:2: cannot find package "kp/models" in any of:
/usr/lib64/golang/src/pkg/kp/models (from $GOROOT)
/home/tjyang/gocode/src/kp/models (from $GOPATH)
home.go:7:2: cannot find package "tpl/helper" in any of:
/usr/lib64/golang/src/pkg/tpl/helper (from $GOROOT)
/home/tjyang/gocode/src/tpl/helper (from $GOPATH)
home.go:8:2: cannot find package "tpl/layout" in any of:
/usr/lib64/golang/src/pkg/tpl/layout (from $GOROOT)
/home/tjyang/gocode/src/tpl/layout (from $GOPATH)
[tjyang@hp1 tpl.out]$

@tjyang

"Add more usage examples" is in our todo. Please be a little bit patient. :p

With regards to this specific issue, please consider use:

gorazor tpl ../tpl instead of gorazor tpl tpl.out

that should fix the cannot find package "tpl/helper"/ "tpl/layout"

For kp/models, it's actually only a dummy package name to show gorazor template accepting model parameter, the model code is not part of the view, so I didn't add it to examples. Before we review the examples, maybe you could change it to something else?

PS: We are actually a startup team, and everyone is busy with project’s feature implementation.

I miss razor the most after moving out the .net world. I'm really happy to have it again in Go. Guessing that there will be people share the same feeling, so I start to send it around, even thought it’s not really a “1.0” version.

Hey, Wuvis.
Thanks for the good work on gorazor. I read through your Chinese readme.md and I like your idea.
Looking forward to learn and contribute in the future.

Existing example/tpl example is too complex for me(beginner).
Can you provide a simple and working "gorazor helloworld.file helloworld.razor.go" example ?

Hi @tjyang ,
I have added a tutorial at ./docs/hello,
Please ask us for any issues.
Thanks.