Giter VIP home page Giter VIP logo

Comments (5)

helgi avatar helgi commented on May 21, 2024

I think this could be useful, especially with multi-arg support. Would you see a version of this wherein the templates the user could simply do each "trim" <args> (trim just being an example, replace with whatever function) in addition to the each* you are suggesting

from sprig.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

I believe that would either require reflection or a big switch which would in turn call the actual function. It could work, but in my experience explicit function calls work better in this case. Since there is a pattern, it's really easy to guess the behavior.

But yeah, that could work.

from sprig.

mattfarina avatar mattfarina commented on May 21, 2024

@sagikazarmark What would the template functions be, what would they work on, and why those things?

I'm trying to understand the end user need and what would be solved.

The technique looks interesting and I could see uses. Just trying to understand why and how to bake it in here. The why and what it solves is important.

from sprig.

boosh avatar boosh commented on May 21, 2024

I came looking for something like this. Actually I wanted to runprintf over elements of a list. I've ended up having to implement my own mapPrintF function but it would have been much more convenient to have just been able to write e.g. {{ map "printf" "values-%s.yaml" .myList }} to return a list where each element has been modified by the printf function. In fact, functional constructs in general (map, reduce, filter, etc.) would be super handy...

from sprig.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

@mattfarina sorry, but I don't remember what the use case was.

I guess the idea is that you can output a list of strings, but apply some filters to it first? Unfortunately I rarely use templates these days. :\

from sprig.

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.