Giter Club home page Giter Club logo

Comments (5)

roboshoes avatar roboshoes commented on August 11, 2024

Hi @k-funk,
sorry for the delay, I've been away from the computer over the last week. This is a pretty known scenario and could actually be used in conjunction with transforms pretty nicely, much like you said. But the implementation won't allow it.

I wonder if we can find a way without ruining the the current intended behavior. I think in the transforms chain, we could allow them on falsy values such as undefined. The _if would only receive the value after transformations, which is still undefined if you don't change that. So it would not break current behavior.

@david-zacharias What do you think. Am I missing something?

from grunt-bake.

david-zacharias avatar david-zacharias commented on August 11, 2024

I am not sure I think we may get trouble with the feature that leaves code in place (removeUndefined set to false). To make that work each transform must check if undefined is given and return it untouched. We should avoid the need for people to change existing transforms... Unfortunately I have not much time at the moment for testing this.

from grunt-bake.

k-funk avatar k-funk commented on August 11, 2024

Maybe now's a good time to start thinking about labeling feature-requests for 2.0.0

from grunt-bake.

roboshoes avatar roboshoes commented on August 11, 2024

I've been thinking about this. I would still love to have a way to supply a default value for variables. One thing that came to mind was the way a lot of people do it in JS: var foo = bar || 14, which would give you 14 in any scenario where bar is falsey, which thanks to the genius of JS is a crazy gray area. 😞

<div>
    Hello {{ name || "new user " }}
</div>

This wouldn't even break the transforms chain:

<div>
    Hello {{ name || "new user" | toUpperCase }}
</div>

What are we thinking. Is the syntax confusing with the single and double pipe?

from grunt-bake.

david-zacharias avatar david-zacharias commented on August 11, 2024

Hi all!

Unfortunately I have not much time at the moment, so just brief feedback:

I would go for @k-funk idea of a default-transform. I think we will find a way to make that work in version 2. This is less confusing I think.

from grunt-bake.

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.