Commit Graph

345 Commits

Author SHA1 Message Date
Tom Alexander
4a21ae5af3
Add tests for explicit context setting that check failure conditions and implement a helper function to generate a new breadcrumb stack. 2020-05-25 15:40:42 -04:00
Tom Alexander
8121c93392
Make the dust template parser all_consuming. 2020-05-25 14:17:38 -04:00
Tom Alexander
5b2ac7c2c2
Add parser support for explicit contexts in helpers. 2020-05-25 14:14:17 -04:00
Tom Alexander
12de0245c5
Implemented parser support for explicit contexts in partials. 2020-05-25 14:05:46 -04:00
Tom Alexander
9031108d2a
Implemented parsing for explicit contexts in NamedBlocks. 2020-05-25 13:55:17 -04:00
Tom Alexander
dbee569931
Finish adding explicit context to the parser for Container. 2020-05-25 13:38:31 -04:00
Tom Alexander
1152ff9974
Greatly expand the explicit_context_setting test.
Turns out explicit context setting works in a lot more places than the official dustjs pages indicate. Also some things don't make much sense (like setting it on a block works but not on an inline partial).
2020-05-24 18:16:16 -04:00
Tom Alexander
c09393da80
Switch the renderer over to using the new is_truthy value and add the injection of $idx and $len into the context tree. 2020-05-24 16:57:24 -04:00
Tom Alexander
966499db76
Switch the get_loop_elements implementation to only return populated arrays when its an array-like object. 2020-05-24 16:27:13 -04:00
Tom Alexander
59ee4f508f
Add a new trait to ContextElement for Truthiness.
Before I was relying on Loopable to both determine truthiness and get a list of elements to loop over. This will no longer work since I need to only set $idx and $len when iterating over actual arrays, as opposed to all truthy values, so I've finally made truthiness explicit.
2020-05-24 16:16:43 -04:00
Tom Alexander
055d88984e
Implement an injected context for iteration values. 2020-05-24 16:01:56 -04:00
Tom Alexander
fff401da7e
Add a test to confirm references are getting parsed. 2020-05-24 15:22:12 -04:00
Tom Alexander
39c579171b
Rename the new functions to replace the old functions. 2020-05-24 15:21:30 -04:00
Tom Alexander
46fe1f5204
Fix the last case by changing the lifetimes and delete the old fractured implementation. 2020-05-24 15:20:36 -04:00
Tom Alexander
4790ac77d6
Initial implementation combining owned_walk_path and walk_path. Works everywhere except one spot. 2020-05-24 14:56:09 -04:00
Tom Alexander
a58b605e59
Add support for dot paths to owned_walk_path. 2020-05-24 14:17:53 -04:00
Tom Alexander
b73561caf9
Add support for literal string blocks. 2020-05-23 23:46:46 -04:00
Tom Alexander
50079c6415
Add support in the renderer for handling paths containing dot. 2020-05-23 23:26:00 -04:00
Tom Alexander
95dc15f103
Update parser to preserve the dot and support paths beginning with a dot. 2020-05-23 23:12:51 -04:00
Tom Alexander
92b9e571be
Array had the same javascript escaping string issue.
Filed a bug at https://github.com/linkedin/dustjs/issues/802 .
2020-05-23 22:37:56 -04:00
Tom Alexander
5424543122
Object also should not turn into a string during javascript escape. 2020-05-23 22:31:33 -04:00
Tom Alexander
7ff1f310f5
Same issue with numbers. 2020-05-23 22:06:25 -04:00
Tom Alexander
71378ed37d
Fix a bug w.r.t. quoting and escaping boolean values with filters. 2020-05-23 19:34:38 -04:00
Tom Alexander
bd7866e973
Implement encodeURIComponent filter. 2020-05-23 19:10:02 -04:00
Tom Alexander
46d4f50410
Implement the encodeURI filter. 2020-05-23 19:06:09 -04:00
Tom Alexander
8d2728a767
Implement javascript string escaping. 2020-05-23 18:40:09 -04:00
Tom Alexander
f3fef17d4b
I was wrong, html escape filter is appended even if an html escape filter is already there. 2020-05-23 18:18:59 -04:00
Tom Alexander
e22bffd2ba
Implemented the json stringify and parse filters. 2020-05-23 18:14:23 -04:00
Tom Alexander
624c83b680
Automatically appending the html escape filter on the renderer side. 2020-05-23 17:57:19 -04:00
Tom Alexander
6a9fe9e1be
Beginning of applying filters for json types. Currently only supports html escaping. 2020-05-23 17:23:48 -04:00
Tom Alexander
5ddeeac966
minor cleanup. 2020-05-17 21:21:26 -04:00
Tom Alexander
93f9581d8a
Renamed the new partial implementation to the old partial name. 2020-05-17 21:17:34 -04:00
Tom Alexander
7be00ffea6
Remove the old partial implementation. 2020-05-17 21:15:03 -04:00
Tom Alexander
ecf2576a0a
Remove default case from render_tag. 2020-05-17 21:12:27 -04:00
Tom Alexander
10c8b25817
Implement the new partial type in the renderer. 2020-05-17 21:11:55 -04:00
Tom Alexander
402d8679e2
Switch the parser over to a new partial implementation for dynamic partials. 2020-05-17 20:44:17 -04:00
Tom Alexander
4645530473
Use the render function when doing string coercion for json values. 2020-05-17 15:52:38 -04:00
Tom Alexander
756fdb7d00
Tests are once again passing. 2020-05-17 00:40:55 -04:00
Tom Alexander
830bb06a92
Unifying number comparison. 2020-05-17 00:27:21 -04:00
Tom Alexander
731f235d9e
fix greater than. 2020-05-16 23:26:33 -04:00
Tom Alexander
03a8328148
Fix the equality test. 2020-05-16 23:19:02 -04:00
Tom Alexander
d77ab7401c
Switched over to using operators instead of compare in the renderer. 2020-05-16 23:10:04 -04:00
Tom Alexander
596611c03a
Mostly implemented the new comparison logic for json with new literals. 2020-05-16 23:07:05 -04:00
Tom Alexander
189dfb1755
Fix tests. 2020-05-16 22:39:29 -04:00
Tom Alexander
c905e705ff
Transition to new literals compiling.
Tests still need work, as does the implementation for json.
2020-05-16 22:31:40 -04:00
Tom Alexander
bc25c1ee16
Starting to remove the old RValues. 2020-05-16 22:19:51 -04:00
Tom Alexander
16d8891452
Implement partial_compare for OwnedLiteral. 2020-05-16 22:08:03 -04:00
Tom Alexander
bf35fd0ae4
equals implementation for literal. 2020-05-16 22:02:58 -04:00
Tom Alexander
6519add838
Starting an OwnedLiteral type instead of using rust's built-in primitives. 2020-05-16 21:52:44 -04:00
Tom Alexander
dd160c5708
Hitting an infinite loop on compare string and int. 2020-05-16 21:34:45 -04:00
Tom Alexander
054480b797
First stab at fixing the error, not a full success. 2020-05-16 21:30:51 -04:00
Tom Alexander
ce8b73f87a
Implement less than or equals. 2020-05-16 19:06:40 -04:00
Tom Alexander
30b7324049
Implement less-than. 2020-05-16 19:05:03 -04:00
Tom Alexander
496a5e0ac7
Had to manually interpret the partial_cmp output instead of using the built-in operators since gte confusingly returns true for mismatched values. 2020-05-16 18:36:47 -04:00
Tom Alexander
62cd73f9c9
Initial attempt at implementation, tests not working. 2020-05-16 18:28:23 -04:00
Tom Alexander
f640cb0440
Fixed greater than helper by using rust's PartialOrd implementation for Vec. 2020-05-16 18:16:07 -04:00
Tom Alexander
b53a9e1837
Cleaning up and factoring out reused code in the renderer. 2020-05-16 17:17:43 -04:00
Tom Alexander
6758d515f1
Have greater than helper very close to correct. Just need to make it compare arrays of scalars. 2020-05-16 16:24:36 -04:00
Tom Alexander
02abee1c53
Add a test for gte. 2020-05-16 15:45:57 -04:00
Tom Alexander
7d4cb14530
Add that check to the not-equals helper and update the json value implementation to mark all non-scalars as not-equals. 2020-05-16 15:30:17 -04:00
Tom Alexander
41e4874d75
Add a check to the equality helper to mark identical paths as equal. 2020-05-16 15:22:48 -04:00
Tom Alexander
6dbeb77a28
Add arrays to all helpers tests. 2020-05-16 14:19:56 -04:00
Tom Alexander
2b5bec05be
Implemented partial_compare for scalar json values. 2020-05-16 14:08:59 -04:00
Tom Alexander
563fd1f6db
Starting comparison of json value to json value. 2020-05-16 13:44:34 -04:00
Tom Alexander
9851a2556d
Ordering implementation for comparison between json and literals. 2020-05-16 13:40:56 -04:00
Tom Alexander
8748cb7063
Structure for ordering, need to implement for serde_json::Value. 2020-05-16 13:31:52 -04:00
Tom Alexander
f4a935224c
Implemented the not equals helper. 2020-05-16 12:26:28 -04:00
Tom Alexander
e04a0be5e7
Add the rest of the helpers to the recursive extract inline partials function. 2020-05-16 12:13:40 -04:00
Tom Alexander
1b63bc4083
Add a test for integer literals. 2020-05-10 23:42:56 -04:00
Tom Alexander
6e6560c742
Revived the tests. 2020-05-10 23:38:59 -04:00
Tom Alexander
c88cab8316
Hook in the integer parser. 2020-05-10 23:13:25 -04:00
Tom Alexander
9ee8f41022
Implement the render send of integer literals. 2020-05-10 23:11:16 -04:00
Tom Alexander
79099a8654
Parsing positive integers. 2020-05-10 23:02:21 -04:00
Tom Alexander
7dd824ab4f
cleaning up. 2020-05-10 22:40:47 -04:00
Tom Alexander
68639481f5
Implement a real clone for ParametersContext. 2020-05-10 22:35:17 -04:00
Tom Alexander
46bb5558ac
Going to a more generic equality comparison for json. 2020-05-10 22:26:47 -04:00
Tom Alexander
6297fa0189
Rename NewParametersContext to ParametersContext. 2020-05-10 22:21:18 -04:00
Tom Alexander
75ba35a422
Cleaning up. 2020-05-10 22:20:39 -04:00
Tom Alexander
6261f7881c
Manual equals is working! 2020-05-10 22:14:07 -04:00
Tom Alexander
2fb7ca9db7
Making CastToAny more generic. 2020-05-10 22:05:48 -04:00
Tom Alexander
9baa669dea
Separating out CastToAny. 2020-05-10 22:04:41 -04:00
Tom Alexander
d5e0c93205
Comparisons between json strings vs rvalue literals is not working as I had hoped. 2020-05-10 21:49:03 -04:00
Tom Alexander
798d84828e
Implemented owned_walk_path. 2020-05-10 21:38:37 -04:00
Tom Alexander
dade738f55
The structure is all there, just need to implement owned_walk_path and clone on NewParametersContext. 2020-05-10 21:34:18 -04:00
Tom Alexander
4e274b9ea5
Running into the walking issue again. 2020-05-10 21:28:47 -04:00
Tom Alexander
137e7887a0
Finish implementing DTHelperEquals. 2020-05-10 21:14:51 -04:00
Tom Alexander
32abe41e1a
Generic implementation of CompareContextElement. 2020-05-10 21:11:49 -04:00
Tom Alexander
256051220d
Generic implementation of CloneIntoBoxedContextElement. 2020-05-10 21:07:31 -04:00
Tom Alexander
ba79369b5a
PartialEq works with results too. 2020-05-10 21:00:52 -04:00
Tom Alexander
7f89685537
PartialEq implemented too. 2020-05-10 21:00:06 -04:00
Tom Alexander
e986a1ba7a
PartialEq compiling with double lifetimes. 2020-05-10 20:58:47 -04:00
Tom Alexander
8fd2a9cf39
tentatively seems to be working. 2020-05-10 19:16:55 -04:00
Tom Alexander
c96b2257d7
Compiling.
Need to see if I can do a generic implemented of IntoBoxedContextElement for all objects implementing Copy, and I need to implement the compare code to make sure this all works before I start integrating this more.
2020-05-10 19:07:41 -04:00
Tom Alexander
5c79b436a0
Commenting out the parameterscontext type. 2020-05-10 19:01:02 -04:00
Tom Alexander
6fb329388f
Not having much luck. 2020-05-10 18:45:54 -04:00
Tom Alexander
b9cfa56c2f
May have to use unsafe code. 2020-05-10 18:35:24 -04:00
Tom Alexander
9573480973
converting the parameters 2020-05-10 18:19:06 -04:00
Tom Alexander
876bced188
Converting RValues. 2020-05-10 18:10:17 -04:00
Tom Alexander
f386e5c31b
Adding trait to cast to Any. 2020-05-10 17:12:15 -04:00
Tom Alexander
c438653449
No luck. 2020-05-10 15:02:59 -04:00
Tom Alexander
7e0e776486
Running into lifetime issues. 2020-05-10 14:53:12 -04:00
Tom Alexander
7a8247f38a
Getting the left and right sides. 2020-05-10 14:22:59 -04:00
Tom Alexander
55f816b53f
Finished implementing Named blocks and inline partials. 2020-05-09 22:49:17 -04:00
Tom Alexander
403f9e6530
Implement a recursive get_block. 2020-05-09 22:40:32 -04:00
Tom Alexander
6837fba489
Passing the block tree through the render functions. 2020-05-09 22:29:58 -04:00
Tom Alexander
9a33195c42
Generating the new treeX 2020-05-09 22:05:43 -04:00
Tom Alexander
d2904913ad
I think I have the full extraction code. 2020-05-09 21:33:10 -04:00
Tom Alexander
ae74ce411a
Getting down to the extract_inline_partials_from_tag function. 2020-05-09 21:09:46 -04:00
Tom Alexander
97e806a968
Start of structure for extracting inline partials from a template. 2020-05-09 21:01:37 -04:00
Tom Alexander
2a9657e3d5
Turns out the issue was the trailing space on the parameters. 2020-05-09 15:15:43 -04:00
Tom Alexander
369fbaf579
works fine with one parameter. 2020-05-09 15:11:04 -04:00
Tom Alexander
710785139a
Works fine with the partial but without parameters. 2020-05-09 15:08:31 -04:00
Tom Alexander
569b4594be
works fine without the partial. 2020-05-09 15:05:29 -04:00
Tom Alexander
bb3449467a
Running into an error parsing one of the partial test templates. 2020-05-09 15:02:54 -04:00
Tom Alexander
bbb9b8d9d3
Partial simple is working. 2020-05-09 14:53:53 -04:00
Tom Alexander
98a0145760
Adding a comment. 2020-05-09 14:33:13 -04:00
Tom Alexander
5d7c991bf0
Simplified the RenderError class. 2020-05-09 14:27:42 -04:00
Tom Alexander
05b56e83a9
Finished creating WalkError. 2020-05-09 14:22:36 -04:00
Tom Alexander
f2f6404017
Compiles again. 2020-05-09 14:18:45 -04:00
Tom Alexander
d758a71fb4
Ported the get_loop_elements wrapper. 2020-05-09 14:14:22 -04:00
Tom Alexander
2712126b3c
Need to do loop elements. 2020-05-09 14:10:56 -04:00
Tom Alexander
fcb2f3fc4d
Going extreme: removing all fields and unifying all walk errors. 2020-05-09 14:00:19 -04:00
Tom Alexander
b20368c586
Starting to create a WalkError type for walking that will not bubble up. 2020-05-09 13:54:39 -04:00
Tom Alexander
7d63d6ef7b
Merge Cant and Wont Walk. 2020-05-09 13:51:02 -04:00
Tom Alexander
2108f5cace
Remove CantRender, it was unused. 2020-05-09 13:46:12 -04:00
Tom Alexander
efd103b84a
Running into a lifetime issue 2020-05-08 22:34:58 -04:00
Tom Alexander
2f515e068d
Implemented the renderer logic.
I should just need to implement ContextElement at this point.
2020-05-08 22:22:30 -04:00
Tom Alexander
b45448edbd
Moved ParametersContext to its own file. 2020-05-08 22:12:35 -04:00
Tom Alexander
1a6db195cb
Starting a context for partial parameters. 2020-05-08 20:58:32 -04:00
Tom Alexander
f240b877b8
Start of rendering partials. 2020-05-08 19:24:32 -04:00
Tom Alexander
dedfa79630
Do a truthiness check on references before printing them. 2020-05-06 20:30:03 -04:00
Tom Alexander
b45688351e
Rendering a reference appears to do a truthiness check because false renders an empty string despite rendering as "false" in an array element. 2020-05-06 20:13:33 -04:00
Tom Alexander
0f47000a9b
Add support for the exists tag. 2020-05-06 19:10:09 -04:00
Tom Alexander
3cf47fa1a8
Rename the new functions to replace the old functions. 2020-05-05 20:46:31 -04:00
Tom Alexander
18f9fb7f57
Delete old render functions. 2020-05-05 20:43:53 -04:00
Tom Alexander
05527377c4
Finish porting over the walk test. 2020-05-05 20:38:42 -04:00
Tom Alexander
9c414d4d06
Fixed rendering else blocks. 2020-05-05 20:32:30 -04:00
Tom Alexander
5760566be0
Start of porting over the walk tests. 2020-05-05 20:22:25 -04:00
Tom Alexander
26fe996b0d
Implement the new render functions. 2020-05-05 19:51:07 -04:00
Tom Alexander
a3bb8e47c1
Implemented the backtracing logic for walking. 2020-05-04 23:45:21 -04:00
Tom Alexander
6bcc66dff5
Adding NotFound error type. 2020-05-04 23:36:13 -04:00
Tom Alexander
033fc9de6b
Implement walking for a single segment, 2020-05-04 23:10:35 -04:00
Tom Alexander
c3fe7b47af
Added a test for backtracking.
DustJS appears to not do any backtracking.
2020-05-03 16:49:34 -04:00
Tom Alexander
45facfed0d
Improve the walk up test to prove that DustJS is doing dynamic scoping, not lexical scoping. 2020-05-03 16:13:29 -04:00
Tom Alexander
e957caf386
Render the else block in sections if the path does not exist or if the path can't be walked.
This fixes all existing compliance tests.
2020-05-03 15:29:02 -04:00
Tom Alexander
cc6dbefcdb
Implement specials in the renderer. 2020-05-03 14:52:08 -04:00
Tom Alexander
bafff8e7a0
Finished transitioning to the new top-level ignored whitespace template element. 2020-05-03 14:44:09 -04:00
Tom Alexander
908ae078b0
Start of making ignored whitespace a top-level template element to handle it in a more generic fashion. 2020-05-03 13:43:49 -04:00
Tom Alexander
b8c59f012b
Expanded the test definition and fixed part of the problem. 2020-05-03 13:21:02 -04:00
Tom Alexander
7670db9259
Identified an issue where tags separated by only whitespace are breaking parsing. 2020-05-03 13:07:27 -04:00