Comments (9)
Hi @troyk ,
sorry for the lack of full documentations. the default arguments in layout should be "".
I try to reproduce your case:
I put all files in and directory example:
example
- index.gohtml
+ layout
app.gohtml
the content in index.gohtml is
@{
import (
"example/layout/app"
)
}
and it do not contains section js,
the Go code generated by gorazor is like
package example
import (
"bytes"
"example/layout"
)
func Index() string {
var _buffer bytes.Buffer
return layout.App(_buffer.String(), "")
}
it should be valid.
Would you please specify more details for your case.
from gorazor.
@chenyukang Thank you so much for looking into this. I have created a repo at https://github.com/troyk/gorazor_debug
I ran gorazor templates/ templates/
from the projects root after deleting and reinstalling all my gorazor source and bin files. I am using go1.3
https://github.com/troyk/gorazor_debug/blob/master/templates/signin.go#L12 is
return layout.App(_buffer.String())
from gorazor.
@troyk ,
Please refer to the PR I send for you,
the import path in your code is not right, it should be "gorazor_debug/templates/layout/app"
gorazor have some conversions on the path, it will try to find the app.gohtml file from the import path according current project path, and then analyze the layout file for arguments.
maybe we'd better report out when path is not expected, I will improve this latter.
thanks!
from gorazor.
@chenyukang Thanks again, did the template build correctly for you with the new path? I merged the pull request, reran gorazor templates/ templates/
and still getting same result
from gorazor.
@chenyukang got it! changed "gorazor_debug/templates/layout/app"
to "templates/layout/app"
, thanks for the help!
from gorazor.
seems I also written a wrong path in PR,
warning message for this should be ok.
from gorazor.
@chenyukang yes, that would be helpful. It might also help to make the difference of the razor import vs go import very clear, and while different, I do like how it resolves so the imports in the layout files are not dependent on the actual pkg path -- makes it easy to share html between packages without creating an entirely seperate pkg. Although some may argue the idiomatic propensity.
from gorazor.
@chenyukang The problem I'm having now is the compiled templates will no compile because the import path in the .go file is templates/layout/app
Shouldn't the .go file use the full package path? github.com/troyk/gorazor_debug/templates/layout/app
?
from gorazor.
@troyk ,sorry for delay replay, Go project have root path(export env path GOPATH),
Like our project, we organize a Demo project like this:
Demo:
+ tpl //this is gorazor template directory, all gohtml files put here
+ src //Go src files
and generate it like this: gorazor tpl ./src/tpl
then all the go files generated by gorazor will stored in src/tpl,
for layout, if you import a layout from a directory, the generated Go code will import layout directory as a package, in your case, it should be gorazor_debug/templates/layout
, so just make sure the directory name in src
is same as your template file directory,
gorazor gorazor_debug src/gorazor_debug
should be ok.
from gorazor.
Related Issues (20)
- some char in template can cause compiled go file can not runable.
- add the option that the gorazor can generate a private function. HOT 1
- License GoRazor? HOT 1
- Not Compatible with idea HOT 2
- panic: Maximum number of elements exceeded. HOT 1
- Change the file case of the gohtml file,build the go file in mac,push it to a git ,pull that git in linux,and build the go file again,you will get two golang files with file case different.And the package will not compile in linux HOT 1
- can you make a idea plugin? HOT 1
- Import models from main package HOT 3
- bug (?) with @raw and variable.variable in range HOT 1
- Sublime Text3 3095版本,高亮问题 HOT 2
- Extra whitespaces in output HOT 1
- if 语句编译bug HOT 1
- for编译不能带len() HOT 1
- any plan to add a parameter indicating remove whitespace(between tags) or not?
- gohtml name cannot have ‘-’ HOT 1
- Issues dealing with CSS directives HOT 1
- package gopkg.in/fsnotify.v1: unrecognized import path
- 请问如何使用啊
- 参考nuxt.js做服务器端渲染框架? HOT 2
- Can't find layout: project/internal/app/templates/layout/base HOT 1
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 gorazor.