Comments (6)
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.
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.
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.
I'd love to see the @contextDump helper extension. debugging is possible , but a bit of a pain , without it.
from ashes.
@jvanasco: given that this issue is closed, I opened #10 on your behalf: #10
from ashes.
Any update on adding select?
from ashes.
Related Issues (20)
- Bug - Ashes doesn't respect kw args in partials HOT 3
- Support raw ouput HOT 1
- docs update or feature request - `load_all` HOT 4
- possible feature idea - cacheable templates HOT 12
- Support partial params HOT 3
- @gt/@lt bug HOT 1
- URL encoding error HOT 2
- Compare to the LinkedIn fork HOT 4
- support linkedin extensions: $idx, $len HOT 3
- Docs - Note any custom helpers/extensions and link to javascript versions if applicable HOT 5
- TemplatePathLoader swaps order of arg/kwarg
- worrisome version numbering HOT 2
- Nested lists broken HOT 5
- [feature request] Make the start and end delimeters of a template token customizeable HOT 4
- [feature request] split out/remove bottle code HOT 5
- Question: any way to extend the library? HOT 2
- consumption tracking
- [feature request] Add @select functionality HOT 1
- Howto reference python functions in templates?
- Opt-in errors when a parameter is missing, or an unused parameter is passed HOT 3
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 ashes.