Giter VIP home page Giter VIP logo

Comments (11)

eastridge avatar eastridge commented on September 14, 2024

@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.

eastridge avatar eastridge commented on September 14, 2024

@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.

kpdecker avatar kpdecker commented on September 14, 2024

Add data: true to the compiler or reference one of the @ vars in the template. Does it still fail?

from thorax.

eastridge avatar eastridge commented on September 14, 2024

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.

eastridge avatar eastridge commented on September 14, 2024

A pull request to fix the issue has been opened here:

handlebars-lang/handlebars.js#390

from thorax.

eastridge avatar eastridge commented on September 14, 2024

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.

candid82 avatar candid82 commented on September 14, 2024

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.

kpdecker avatar kpdecker commented on September 14, 2024

@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.

eastridge avatar eastridge commented on September 14, 2024

@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.

eastridge avatar eastridge commented on September 14, 2024

@kpdecker @candid, closing this ticket, check out:

#73

from thorax.

kpdecker avatar kpdecker commented on September 14, 2024

@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)

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.