Comments (11)
@candid @kpdecker I wasn't aware of the existence of private vars until very recently. Is there any documentation on them at all? Can't find anything on the handlebars website other than a single mention of @index
. No objection to using them instead of an actual variable, will try it out.
from thorax.
@kpdecker, ran into a bit of a bummer, which is that helpers don't receive data downstream from each / with. I wrote a failing test case:
https://github.com/eastridge/handlebars.js/commit/7ce13a3c2c0dce9a00a5b569f41fa6361d281312
Is this the expected behavior? If it is the private variable solution won't work for us. If it isn't I'll see if I can make a fix.
from thorax.
Add data: true to the compiler or reference one of the @ vars in the template. Does it still fail?
from thorax.
Adding a @ var in the template does make it show up in the context, but we want it to be available wether or not it's actually declared in the template. Is this desired behavior? Also, what flag would I set on the compiler? Not setting anything now but would need to be something that is both available in precompiling mode and via Handlebars.compile
.
from thorax.
A pull request to fix the issue has been opened here:
handlebars-lang/handlebars.js#390
from thorax.
A branch implementing this is here:
https://github.com/walmartlabs/thorax/tree/private-vars
We need the pull request on wycats/handlebars.js to get merged for this to proceed as requiring {data: true}
to be passed to Handlebars.compile
is a recipe for trouble. If the pull request is rejected (lil help @kpdecker ;) we can revisit wether we want to impose this requirement.
Also seems like the {{cid}} var should move to be a private var. @candid @jhudson8 are there any other useful always available private vars you guys have wanted available?
from thorax.
My experience with private vars is limited to a few hours of dealing with @Index. I will let you know if I run into other cases where they would be helpful.
from thorax.
@eastridge I think the cid is a good candiate to move over.
On the upstream default can we detect when data isn't provided in a particular template and warn? Can you create a PR for the private-var branch?
from thorax.
@kpdecker Ok, hopefully we can get some traction on handlebars-lang/handlebars.js#390 but if not I think throwing an error is a good stopgap. Can you make the needed change in lumbar, or is it a config option I can pass somewhere?
from thorax.
@kpdecker @candid, closing this ticket, check out:
from thorax.
@eastridge adding "data": true
to the precompile
config section in lumbar should do the trick. I'll update the shared lib for this.
from thorax.
Related Issues (20)
- Allow for document and window event binds HOT 1
- View properties inheritance HOT 3
- url helper and pushState HOT 4
- Missing 3.x tags make bower dependencies unavailable
- Wrapping nth items view within a div.row HOT 1
- CollectionView: Support for header and footer HOT 1
- Investigate Htmlbars HOT 1
- CollectionView not removing items from this.children on sort event HOT 1
- validation error HOT 1
- Thorax Architecture Example Page 404 HOT 4
- Empty item templates produces holes in collection HOT 2
- this.model is null in collection view's initialize method
- Form inputs are not updated on re-render HOT 5
- CollectionView itemFilter doesn't work when itemView is used
- Mark as abandoned? HOT 2
- How to get started with thorax HOT 3
- Thorax + Bootstrap, event not correctly trigger HOT 1
- Rendering a table via collection? HOT 1
- Announce discontinued maintenance in the readme / docs HOT 2
- Ensure all tagged versions are on npm
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 thorax.