GithubHelp home page GithubHelp logo

Generalize template generation about modelq HOT 7 CLOSED

mijia avatar mijia commented on September 28, 2024
Generalize template generation

from modelq.

Comments (7)

mijia avatar mijia commented on September 28, 2024

@tarqe39 Hi, thank you very much for your interest. Would you like to provide a more detail example for this? :)

from modelq.

dfilipovic39 avatar dfilipovic39 commented on September 28, 2024

I need to use sqlx, custom context and so on, so gmq will not work for me.
It would be nice if i could define my own template with sections /fragments that correspond to your templates(in templates.go). The tool would then generate code from my templates.
I could do a pull request if you want so you can see what i mean.

from modelq.

mijia avatar mijia commented on September 28, 2024

@tarqe39 Ah, got you, would you like to provide me a sample of the target code or the template so I can generalize this feature? Thank you very much.

from modelq.

dfilipovic39 avatar dfilipovic39 commented on September 28, 2024

content of template doesnt matter, it can be anything. idea is to load file with multiple sections and render them instead of current templates. they would replace current templates tmHeader, tmStruct, tmObjApi, tmQueryApi, tmManagedObjApi.
here is a sample for single template with multiple sections.
http://play.golang.org/p/Q3NMOymzfT

you would call CLI with something like modelq -db="root@/blog" -pkg=mysql -tables=user,article -driver=mysql -schema=blog -templates=myTemplates.tmpl

from modelq.

mijia avatar mijia commented on September 28, 2024

Got it, make sense to me, will do this, :)

from modelq.

mijia avatar mijia commented on September 28, 2024

Hi @tarqe39 sorry for so late, have been kept busy for these days. I kinda commit the feature into master and now the template is supported. Please check the examples/custom.tmpl for example and the generated codes are listed in examples/custom.

Please let me know if the basic fragments or the template arguments are not enough for you requirements. :)

from modelq.

dfilipovic39 avatar dfilipovic39 commented on September 28, 2024

Haven't tried it yet, but I looked at changes and example and it looks good :) thx

from modelq.

Related Issues (19)

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.