Giter Club home page Giter Club logo

Comments (6)

mahmoud avatar mahmoud commented on August 20, 2024

So I went ahead and added preliminary versions of eq, ne, gt, gte, lt, and lte. Right now there's no type coercion, mostly because it's late-ish, but there is the whole javascript/python type system incompatibility that I don't want to inflame. For one, I'll need to have ashes alias boolean to bool and string to str so that templates can be continue to be used on both the front- and back-ends.

Also, there's a new size helper that works mostly the same as LinkedIn's (some departures, mostly in that it doesn't try as hard if the value doesn't actually have a len()).

While I was at it, I added a couple that weren't in LinkedIn's but are handy: an idx_1 helper for 1-based indexing, as well as a first and last matching helper duo. The mechanism is almost identical to sep, to the degree that should you find yourself desiring an even and odd, just take a glance and the code.

Now, more decisions. I don't think it's such a good idea to try and mirror the if and math helpers. if uses eval() and the code in the condition can pretty much be arbitrarily complex javascript. Don't want to invite incompatibility, esp when the simple comparators probably mostly cover it. Likewise with math; I don't much see much need. I prefer putting that stuff with the rest of the logic. Also probably not going to do contextDump right away, unless requested. Debuggy things like that can just be implemented and shoved into the render model/context on a one-off basis.

The only one that still sort of hangs in the balance is select which does a very useful thing: variable-based key lookup. Dust has felt a bit limiting at times without that, but I don't know if select is really the best construct for achieving this end. I'll probably have to write some more templates of my own before I can decide. ;)

Anyhoo, closing this. If you run into any bugs, you know where to find me.

from ashes.

plowman avatar plowman commented on August 20, 2024

This is extremely cool. I will start using some of the new functionality and let you know if I see any bugs (or submit pull requests).

from ashes.

mahmoud avatar mahmoud commented on August 20, 2024

Miniupdate: 105334b added comparison helper type coercion for boolean, string, and number. date and context are just not pressing enough in my book, and fully replicating javascript's craycray comparisons (and Date type) is a suicide mission.

All that said, normal usage should work exactly as expected, and nothing should explode (the default behavior on coercion failures and unrecoverable type mismatches is to just return False), so let me know if a helper ever raises an exception.

from ashes.

jvanasco avatar jvanasco commented on August 20, 2024

I'd love to see the @contextDump helper extension. debugging is possible , but a bit of a pain , without it.

from ashes.

mahmoud avatar mahmoud commented on August 20, 2024

@jvanasco: given that this issue is closed, I opened #10 on your behalf: #10

from ashes.

gajewsk2 avatar gajewsk2 commented on August 20, 2024

Any update on adding select?

from ashes.

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.