Comments (5)
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.
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.
Maybe now's a good time to start thinking about labeling feature-requests for 2.0.0
from grunt-bake.
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.
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)
- Version for gulp HOT 1
- When in '_section', use properties outside this '_section' HOT 11
- Evaluate content inside of _section HOT 1
- Add variable for linking to originating file when using _bake-attribute HOT 2
- Integration of default transforms HOT 1
- Pass arrays/objects as inline attributes HOT 9
- Can't access properties in _section HOT 1
- bake-escape feature request HOT 20
- JSON file or CSV convert to multiple HTML files HOT 9
- Simple bake test HOT 1
- foreach loop to build multiple files per object HOT 1
- Unset variables are rendered as "undefined" HOT 3
- Assign/use variable in same file HOT 1
- Builtin placeholders HOT 2
- How to convert a folder with bake ? HOT 2
- Generate Bake with grunt.config.get HOT 2
- Bake one HTML file / JSON section in one go HOT 5
- Iteration over objects in _foreach HOT 6
- Can I read from package.json? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-bake.