GithubHelp home page GithubHelp logo

Comments (9)

chenyukang avatar chenyukang commented on July 20, 2024

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.

troyk avatar troyk commented on July 20, 2024

@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.

chenyukang avatar chenyukang commented on July 20, 2024

@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.

troyk avatar troyk commented on July 20, 2024

@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.

troyk avatar troyk commented on July 20, 2024

@chenyukang got it! changed "gorazor_debug/templates/layout/app" to "templates/layout/app", thanks for the help!

from gorazor.

chenyukang avatar chenyukang commented on July 20, 2024

seems I also written a wrong path in PR,
warning message for this should be ok.

from gorazor.

troyk avatar troyk commented on July 20, 2024

@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.

troyk avatar troyk commented on July 20, 2024

@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.

chenyukang avatar chenyukang commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.