-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new math helper method #99
Conversation
source: '<div>{@math expression="1 * 5"/}</div>', | ||
context: {}, | ||
expected: "<div>5</div>", | ||
message: "testing mutiplication with math helper" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments
the expressions should support dynamic args such as the $idx in the loop or even the value in the context/ JSON ( so we should use the tap method )
I really dont see a use case yet where this comes handy,
can you tell me about your use case where this helper comes handy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This originally came out of wanting to do modulus on idx and otherwise. We can down-scope this to have specific helpers - modulus, ceil, floor, random, etc. rather than a general method.
Jimmy had a suggestion of using nth-child selectors for modulus, but I feel that is mixing metaphors. I would prefer to have a specific modulus helper if the math/eval helper is deemed a bad idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @sclatter , we shall resolve this tomm meeting for sure.
Per the email thread, changed the generic math helper to a mod (modulus) helper and updated the unit tests. Please review and let me know if anything else is required. |
How do you feel about leveraging the I added the automatic lookup of $idx in |
Jimmy, I like leveraging the filter and defaulting to $idx. I would prefer to use "dividend" instead of "key" to stick with the proper mathematical term, since we are billing these as math helpers. Sarah |
|
One option is to add another layer to the lookup:
Reusing the |
@jimmyhchan I dont like so many variations, just makes its much harder and leads to more bugs Lets keep it simple then, use dividend, dont tie this to select why cant we make idx explicit ? assuming too many things inc ode mean more to learn for a dev |
|
I like @rragan 's suggestion. Let's go with that - more straightforward and extensible. Me or Jimmy to code? I have some time this aft and Monday. |
@jimmyhchan - yes, I'm on it! Thanks. |
…re extensible than second version, unit tests
Hi all, I have committed my latest math helper. Please review. If it is to your liking, I can work up the documentation today. Thanks, |
var method = params.method; | ||
var operand = params.operand || null; | ||
var operError = function(){_console.log("operand is required for this math method")}; | ||
var returnExpression = function(exp){chunk.write( eval( exp ) )}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we are explicitly defining the method, can we get rid of this eval?
Removed eval. Thanks, Jimmy! I feel we should hold off on the body thing as to keep it simple for now. That can be added later without disrupting backward compatibility. |
merge it! agreed. awesome work btw. |
Please accept my new math helper method. :)
-Sarah