Commit Graph

479 Commits

Author SHA1 Message Date
Tom Alexander
cdd10576e8
Wire up serde_json for the math functions. 2020-06-13 22:55:38 -04:00
Tom Alexander
431b34dac7
Wired up the OwnedLiterals to the math functions. 2020-06-13 22:52:07 -04:00
Tom Alexander
fdd467298a
Finish the MathNumber implementations. 2020-06-13 22:46:03 -04:00
Tom Alexander
f783f45d24
Implement the 2-number math functions for MathNumber. 2020-06-13 22:32:30 -04:00
Tom Alexander
0a2e1b007c
Add stubs for MathNumber. 2020-06-13 22:23:40 -04:00
Tom Alexander
d8b8c223f0
Add stubs for the math functions. 2020-06-13 22:12:00 -04:00
Tom Alexander
2c5c2d239c
Add a special case to not render anything if the method parameter to the math helper is a template to match the official DustJS implementation. 2020-06-13 22:03:48 -04:00
Tom Alexander
b897656cef
Fix all of the math test except for block template-based methods. 2020-06-13 21:37:11 -04:00
Tom Alexander
d9f10290f5
Math helper nearly done, test almost passes. 2020-06-13 21:28:21 -04:00
Tom Alexander
28a4fea96f
Remove RValue from ParametersContext so I can re-use it for calculated values from math. 2020-06-13 21:13:16 -04:00
Tom Alexander
e6c17fb603
Bodiless math is now working in the simple cases. 2020-06-13 20:02:48 -04:00
Tom Alexander
dcbf8e83f6
Implement number casting. 2020-06-13 19:55:40 -04:00
Tom Alexander
9eb70f436c
Starting a type casting trait 2020-06-13 19:39:31 -04:00
Tom Alexander
11096d7ece
Bodiless math implementation. 2020-06-13 19:28:45 -04:00
Tom Alexander
241f6c04e4
Rename JsonNumber to ComparisonNumber. 2020-06-13 19:15:51 -04:00
Tom Alexander
d6ad7c28f3
Move MathNumber into the library.
While this will be used for the OwnedLiterals since they must always exhibit the original DustJS behavior, I am going to keep exposing separate math functions for ContextElement instead of simply requiring them to implement Into<MathNumber> since people might want to implement math in unusual ways with unusual types.
2020-06-13 19:13:02 -04:00
Tom Alexander
d9ce011113
Add implementation based on MathNumber. 2020-06-13 19:02:56 -04:00
Tom Alexander
df0ae05648
Start of implementation for serde_json but I'm going to change my approach.
The permutations are pretty intense, so I think I'm going to do the same design I did for comparison where I have a JsonNumber (but I'll call this one MathNumber and rename JsonNumber to ComparisonNumber), convert the types to that, and then do the math.
2020-06-13 18:34:13 -04:00
Tom Alexander
db11677b22
Implement addition for OwnedLiterals. 2020-06-13 17:50:22 -04:00
Tom Alexander
8ef3949a65
Fix float json to literal equality comparison by casting them both to float. 2020-06-13 16:32:57 -04:00
Tom Alexander
de5932b4c6
Fix bug in parsing order for literals. 2020-06-13 16:23:46 -04:00
Tom Alexander
2a89fd826e
Update tests to use templates instead of literal strings for string parameters. 2020-06-13 16:18:48 -04:00
Tom Alexander
d99aa44d8e
Add support for negative integers. 2020-06-13 16:06:31 -04:00
Tom Alexander
02bcefb75c
Remove outdated TODO. 2020-06-13 15:33:21 -04:00
Tom Alexander
03ff75b2de
Fix number comparison logic. 2020-06-13 15:31:52 -04:00
Tom Alexander
4d28120732
I have broken the comparison function. 2020-06-13 14:55:27 -04:00
Tom Alexander
5b656a44ad
For partial_cmp, convert OwnedLiterals into serde_json values. 2020-06-13 14:19:03 -04:00
Tom Alexander
a378d6e6f3
Add comparisons for json floats but not yet between OwnedLiterals and json. 2020-06-13 13:47:43 -04:00
Tom Alexander
978bbe6eb3
Implemented float literals for OwnedLiterals, not yet for serde_json. 2020-06-13 13:37:26 -04:00
Tom Alexander
8daa746da6
Initial structure for the perform_math_operation function. 2020-06-13 13:16:25 -04:00
Tom Alexander
6877e3d393
Add parser support for the math helper. 2020-06-13 12:03:55 -04:00
Tom Alexander
c5db1cea8f
Add a test case for the math helper and add else blocks to the select test. 2020-06-13 11:45:45 -04:00
Tom Alexander
c06cc61a07
Merge branch 'helper_select' into render 2020-06-07 19:11:37 -04:00
Tom Alexander
a937a12db6
Cleanup. 2020-06-07 19:11:21 -04:00
Tom Alexander
88887bff0f
Implemented early termination. 2020-06-07 19:10:25 -04:00
Tom Alexander
0fac063c8d
Implemented none and any, but I need to implement early termination. 2020-06-07 18:52:09 -04:00
Tom Alexander
f1b868ce33
I think I have the code for the select tag finished, but I haven't yet implemented any or none. 2020-06-07 18:44:27 -04:00
Tom Alexander
576d94780a
Implement a SelectContext for passing the select parameters and whether or not any comparison passed down exactly 1 level in the renderer. 2020-06-07 18:33:34 -04:00
Tom Alexander
b0b857147d
Implemented code to find out if any comparison checks inside a select are true. 2020-06-07 18:27:11 -04:00
Tom Alexander
ed38ce6a38
Unified the renderers for all the comparison helpers by moving their implementation to perform_comparison_check. 2020-06-07 18:17:28 -04:00
Tom Alexander
85d36fc516
Implemented perform_comparison_check to separate the comparison logic from the render code so that it can be used pre-rendering by the select helper. 2020-06-07 18:11:14 -04:00
Tom Alexander
f2740987ec
Add a parent to ParametersContext so we can chain parameters contexts for use with the select helper. 2020-06-07 17:56:51 -04:00
Tom Alexander
a61807d84c
Add parser support for select/any/none. 2020-06-07 17:06:14 -04:00
Tom Alexander
84c07b262c
Add a test for the select helper. 2020-06-07 16:50:11 -04:00
Tom Alexander
a749f91e8e
Ported over the comparison helpers to using the new tap function. 2020-06-07 16:49:15 -04:00
Tom Alexander
b35874f19e
Merge branch 'helper_sep' into render 2020-06-07 15:19:29 -04:00
Tom Alexander
78dad3273a
Remove $len from first helper since its not needed. 2020-06-07 15:18:03 -04:00
Tom Alexander
417466d17d
Implement the first and last helpers. 2020-06-07 15:16:39 -04:00
Tom Alexander
fdecdcb53b
Implemented the sep helper. 2020-06-07 15:09:37 -04:00
Tom Alexander
3fb91566bb
Implement get and tap functions. 2020-06-07 14:45:32 -04:00