Commit Graph

404 Commits

Author SHA1 Message Date
Tom Alexander
0302ed216f
Add my implementation of a take_until_parser_matches parser.
The author of nom is too busy to review the PR, and cargo does not allow for git dependencies, so I am going to copy my implementation into this code base so I can use upstream nom so I can push to cargo. While this code has been submitted upstream to nom which is under the MIT license, I am the author of this code so I believe I have the full right to also release it in this project under the 0BSD license.
2021-02-06 16:23:54 -05:00
Tom Alexander
b4dd4cebfd
Expose the integrations through the library so they can be used outside this project. 2020-12-30 15:17:48 -05:00
Tom Alexander
900d929869
Move the json integration to its own file to keep the serde stuff separate. 2020-12-29 18:21:12 -05:00
Tom Alexander
a9a83d1b4a
Update for the latest nom and make serde an optional dep. 2020-12-29 18:07:49 -05:00
Tom Alexander
a622a7e1bc
Add an is_castable() function to stop casting to number for booleans in the @size helper. 2020-06-14 18:27:28 -04:00
Tom Alexander
c300d18a75
Implement the outstanding type casts for serde_json. 2020-06-14 17:59:57 -04:00
Tom Alexander
021a7bd739
Implement the outstanding type casts for OwnedLiterals. 2020-06-14 17:37:51 -04:00
Tom Alexander
eb3b1ae30a
Add stubs for casting the new OwnedBooleans. 2020-06-14 17:23:54 -04:00
Tom Alexander
83c86ff9b3
Move ComparisonNumber into the library and add an OwnedLiteral for booleans. 2020-06-14 17:08:01 -04:00
Tom Alexander
8ab315abfe
Adding stubs for type casting to string and boolean. 2020-06-14 16:38:55 -04:00
Tom Alexander
d47e004084
Implement logic in comparison helpers to perform type casting. Casting to non-number not yet implemented. 2020-06-14 16:30:21 -04:00
Tom Alexander
5dff03bb37
Add a test case for type casting to the equality helper tests. 2020-06-14 16:20:07 -04:00
Tom Alexander
4731ddaa6b
Remove unused import. 2020-06-14 16:02:04 -04:00
Tom Alexander
92c65a109b
Implement the contextDump helper. 2020-06-14 15:50:22 -04:00
Tom Alexander
648ae5dfdb
Turns out I was wrong, the @size helper attempts to cast to a number regardless of the input and it uses that. Fixed the test. 2020-06-14 15:20:54 -04:00
Tom Alexander
e70f397545
First attempt at fixing by reading all indirect references containing a reference to a single value as the original value is a failure. Turns out the @size helper treats numeric types in indirect references differently. 2020-06-14 14:51:31 -04:00
Tom Alexander
716a110d2e
Added some notes about observed behavior and fixed return types for missing/absent keys. 2020-06-14 14:13:33 -04:00
Tom Alexander
69fa266692
Allow spaces before closing braces on tags without parameters.
Previously I incorrectly only supported spaces before closing braces on tags with parameters. This patch expands that behavior to all tags.
2020-06-14 13:29:01 -04:00
Tom Alexander
44d54c86d2
Implement the size helper but it has a bug somewhere. 2020-06-14 13:16:52 -04:00
Tom Alexander
a6c22417e5
Implement Sizable for both OwnedLiterals and serde_json. 2020-06-14 13:06:03 -04:00
Tom Alexander
1a54e35736
Add tests and a Sizable trait for ContextElement. 2020-06-14 12:54:03 -04:00
Tom Alexander
76193bf806
Stubs for the size and contextDump helpers. 2020-06-14 12:32:10 -04:00
Tom Alexander
c5a0ad6786
Wire up the math functions to the renderer. 2020-06-13 23:01:29 -04:00
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