Git Product home page Git Product logo

Comments (3)

samcoe avatar samcoe commented on June 2, 2024 1

@heaths Allowing the template package to be extendable sounds like a good idea to me. I am thinking something like:

func (t *Template) RegisterFunc(name string, f func(fields ...interface{}) (string, error)) error

Where the RegisterFunc would add the new function to t.templateFuncs which is not stored on the Template struct yet, but could be added there. What do you think?

This could even be used to override default template functions if we want to allow that behavior.

from go-gh.

mislav avatar mislav commented on June 2, 2024

Go stdlib already supports templating with extensible functions in its text/template package. Why would we replicate that functionality?

The reason why we've publicized our pkg/template is to give extension authors access to the --template functionality from CLI. But if other kind of functionality is needed, one that doesn't exist in --template, my suggestion for extension authors would be just to drop down to stdlib text/template.

from go-gh.

heaths avatar heaths commented on June 2, 2024

The point would be to get all the functions that CLI already defines for use in extensions. That's what I had to do with one of my extensions because I can't add some others. Overriding a function isn't really a major goal, but figured "just in case".

from go-gh.

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.