Commit Graph

345 Commits

Author SHA1 Message Date
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
Tom Alexander
f97bb25ca8
Integrated the new span class 2020-05-03 12:48:02 -04:00
Tom Alexander
b8e8f19724
Implemented a new span to trim leading whitespace.
Through my experiements I have concluded that DustJS trims whitespace at the front of a line. To handle this, I implement a new parser that matches a newline followed by any amount of whitespace. This should allow me to trim whitespace at the head of the line because spans start immediately after a tag is closed. So, for example:

```
{foo}
  bar
{/foo}
```

Would be:

```
{foo}\n  bar{/foo}
     ^     ^
     \____/
      span
```

So while there is no magical "start of line" detector like in regular expressions, the first start of a line in a span will always be preceded with a newline character except for the opening of the document. For handling the opening of the document I am already trimming the whitespace in the `template()` parser.
2020-05-03 12:28:55 -04:00
Tom Alexander
9a261aa870
Fixed lifetime issue 2020-05-02 16:08:39 -04:00
Tom Alexander
7b87e30ff9
Fixed returns but hitting lifetime issue 2020-05-02 16:04:10 -04:00
Tom Alexander
caa79d5ba2
Moving towards a generic trait wrapper to call between dynamic and static dispatch functions. 2020-05-02 15:55:38 -04:00
Tom Alexander
f0a69d12b9
First attempt at a section render function.
Running into an issue with generics vs dynamic references.
2020-04-28 20:46:29 -04:00
Tom Alexander
e5c4ba8c82
Add a Loopable trait for dust sections. 2020-04-28 19:34:52 -04:00
Tom Alexander
c961cf7ab8
Combine the render traits into a single context_element file. 2020-04-28 19:09:02 -04:00
Tom Alexander
41ad6179d1
Parse self-references and add a test for sections. 2020-04-28 19:02:43 -04:00
Tom Alexander
8e4f5e3229
Fixing warnings 2020-04-12 21:57:42 -04:00
Tom Alexander
883bda7a78
Added the signature for passing filters into the render function.
Added the signature for passing filters into the render function but I am not yet using the filters.
2020-04-12 21:54:15 -04:00
Tom Alexander
70cb107f86
Removing unused imports 2020-04-12 21:44:38 -04:00
Tom Alexander
7a28e6a9d4
Handle rendering json arrays and objects 2020-04-12 21:40:34 -04:00
Tom Alexander
24d2c1831c
Handle missing references 2020-04-12 21:26:23 -04:00
Tom Alexander
0c4e97c556
typo 2020-04-12 21:14:21 -04:00
Tom Alexander
610adc8b72
Switch the Renderable trait over to the returning a RenderError 2020-04-12 21:09:03 -04:00
Tom Alexander
9c7883358a
Better error handling added to walkable 2020-04-12 20:52:30 -04:00
Tom Alexander
a647ed6d43
fix tests 2020-04-12 18:31:27 -04:00
Tom Alexander
d51392fe8a
Initial move to returning results from render calls. 2020-04-12 18:29:40 -04:00
Tom Alexander
d30749f709
Updated to the latest nom 2020-04-12 17:39:24 -04:00
Tom Alexander
28b5cf1d34
Fix handling of surrounding whitespace 2020-04-12 16:02:26 -04:00
Tom Alexander
db575d145e
Initial attempt at docker compliance tests. 2020-04-12 14:37:54 -04:00
Tom Alexander
542c2c4536
Switching render_template to render_body.
The body element is re-used as a child element in blocks, so it makes more sense to make a function that renders that as opposed to a function that renders a top-level-only container that contains only a body.
2020-04-11 23:03:07 -04:00
Tom Alexander
869c32df21
Moving the custom types for the walk_path test inside the test function 2020-04-11 22:54:48 -04:00
Tom Alexander
273f6204d8
Rendering my first template with actually following paths.
Before I was hard-coding the path to the reference. Now I am following the full path programmatically using the new ContextElement and Walkable traits.
2020-04-11 22:52:20 -04:00
Tom Alexander
e5e1703fab
Implement ContextElement for serde_json::Value 2020-04-11 22:47:31 -04:00
Tom Alexander
dbfa7ea4dc
Cleaning up 2020-04-11 22:36:22 -04:00
Tom Alexander
47bb055b67
I think its working 2020-04-11 22:23:59 -04:00
Tom Alexander
5efa650b67
Switching to a combined ContextElement trait for Walkable and Renderable 2020-04-11 22:19:54 -04:00
Tom Alexander
07e5c9f0af
turns out putting dyn everywhere fixes it 2020-04-11 22:04:44 -04:00
Tom Alexander
c094997032
Getting rid of some lifetimes 2020-04-11 21:59:21 -04:00
Tom Alexander
5098ee6338
Switching over to dyn Walkables 2020-04-11 21:57:24 -04:00
Tom Alexander
ec3276af79
Much cleaner with impl walkable but don't know if I can loop yet 2020-04-11 21:51:12 -04:00
Tom Alexander
110b03fc45
Going to try returning impl trait before resorting to boxing 2020-04-11 21:44:42 -04:00
Tom Alexander
43e57f4134
setup for moving into a multi-step walk function 2020-04-11 21:26:36 -04:00
Tom Alexander
f62d50df95
Taking 1 step in a deep context is working! 2020-04-11 21:20:45 -04:00
Tom Alexander
d89d3d9f3c
Added another test proving do_the_walk is now generic 2020-04-11 21:13:21 -04:00
Tom Alexander
54e6613f14
do_the_walk may be generic now? 2020-04-11 21:12:42 -04:00
Tom Alexander
c647301662
removing unnecessary lifetime 2020-04-11 21:08:33 -04:00
Tom Alexander
9e1f102540
removing unnecessary static 2020-04-11 21:07:39 -04:00
Tom Alexander
63124bc6e3
Adding &str 2020-04-11 21:07:12 -04:00
Tom Alexander
d296ad6b56
Maybe have a generic implementation of walkable working 2020-04-11 21:03:21 -04:00
Tom Alexander
7ace4be3c7
working on two levels 2020-04-11 20:34:16 -04:00
Tom Alexander
d5c3985c29
initial walkable implementation 2020-04-11 20:31:44 -04:00
Tom Alexander
15c8ee57a7
Successfully rendering my first template. 2020-04-11 19:19:40 -04:00
Tom Alexander
e26b158ab4
Initial implementation of custom Renderable trait. 2020-04-11 19:11:14 -04:00
Tom Alexander
af5122ab9f
Figured out how to get a value using to_string()
Figured out how to get a value using `to_string()` but serde_json's `to_string()` is wrapping a string in quotes. I think I want to implement my own trait to support custom logic for rendering values.
2020-04-11 19:05:50 -04:00
Tom Alexander
265afe7eeb
I think I figured out how to get the Index trait back into the generic type. 2020-04-11 19:05:50 -04:00
Tom Alexander
f65a144b3c
Beginning of the render_tag function.
Beginning of the render_tag function. At this point I need to figure out how to access elements in the context.
2020-04-11 19:05:40 -04:00
Tom Alexander
2459d7b418
Rendering spans 2020-04-11 18:25:48 -04:00
Tom Alexander
13934e8699
Rename DustContext to DustRenderer 2020-04-10 20:58:55 -04:00
Tom Alexander
2842d0a14a
Loading the compiled templates into a context 2020-04-10 20:55:44 -04:00
Tom Alexander
743106684a
compiling templates in the same manner as the shim 2020-04-10 20:27:27 -04:00
Tom Alexander
7e0a617ba6
Add support for supplying multiple templates to the dustjs shim to support testing partials. 2020-04-10 19:07:02 -04:00
Tom Alexander
05d9e20a8f
Add all the helpers 2020-04-07 21:49:28 -04:00
Tom Alexander
15c732b3a3
Also stealing the ParameterizedBlock struct 2020-04-07 20:37:15 -04:00
Tom Alexander
b7120a34de
Forking the partial code for reuse as helper code 2020-04-07 20:21:26 -04:00
Tom Alexander
2ebe4798d5
Add test for quoted partial 2020-04-07 19:53:57 -04:00
Tom Alexander
e2f03de297
Integrated the partial parser into the rest of the grammar 2020-04-07 19:51:06 -04:00
Tom Alexander
8bfa622c4c
parsing out string literals in addition to paths 2020-04-06 23:47:50 -04:00
Tom Alexander
79100fc50f
Introducing a KVPair type 2020-04-06 23:35:09 -04:00
Tom Alexander
dd8b4ac28c
Introducing an RValue enum to handle paths vs literals 2020-04-06 23:30:42 -04:00
Tom Alexander
8641e5a98b
Starting stand-alone parsers for key value pairs 2020-04-06 23:21:03 -04:00
Tom Alexander
ffce2b0569
The extra steps are making it harder to debug, so move parser directly into test 2020-04-06 22:47:24 -04:00
Tom Alexander
647c22b3a9
Initial scaffold for partials 2020-04-06 22:02:10 -04:00
Tom Alexander
989bc6ed2a
Added backslash to the quoted string test 2020-04-06 21:26:08 -04:00
Tom Alexander
a6e48aee6a
Switch to escaped_transform to unescape the text. 2020-04-06 21:09:06 -04:00
Tom Alexander
5463ed2cdf
Added surrounding quotes 2020-04-06 21:03:03 -04:00
Tom Alexander
878cbf56ca
Switch to raw strings 2020-04-06 20:47:17 -04:00
Tom Alexander
a0b032ad4b
I was missing an escape character 2020-04-06 20:45:39 -04:00
Tom Alexander
586823aa8a
first test case failing 2020-04-06 20:34:04 -04:00
Tom Alexander
b3120d2e52
Initial scaffold for developing a quoted string parser 2020-04-06 20:20:53 -04:00
Tom Alexander
41abcb9b4a
Add support for named blocks 2020-04-05 23:47:55 -04:00
Tom Alexander
52824b4d0b
Rename the container parser to conditional.
Rename the container parser to conditional because we are going to have other tags with bodies that do not match the same semantics as the conditional blocks. An example of this is inline partials only support a single key rather than a path.
2020-04-05 19:39:07 -04:00
Tom Alexander
de4f420627
separate out the parser for key because partials don't use a full path, only a key 2020-04-05 19:34:46 -04:00
Tom Alexander
7f2c7151a9
Rename Block to Body because dust uses the name Block for {+ 2020-04-05 19:29:16 -04:00
Tom Alexander
fb17911c44
Change repo to generate both a library and a binary.
This repo will primary be a library, but for compliance testing it may make sense to have a binary operating in the same fashion as the node dustjs shim so I've set up this repo to generate both a library and a binary.
2020-04-05 19:21:43 -04:00
Tom Alexander
0d659afa2f
Rename duster module to parser 2020-04-05 19:21:43 -04:00
Tom Alexander
34882024b3
Add support for else blocks 2020-04-05 19:21:42 -04:00
Tom Alexander
9da8ea7294
Add support for self-closing containers 2020-04-05 19:21:42 -04:00
Tom Alexander
fff229df90
Integrated exists and not exists containers 2020-04-05 19:21:41 -04:00
Tom Alexander
5f297eca78
Beginning of creating a generic Container parser 2020-04-05 19:21:40 -04:00
Tom Alexander
7d51e500d8
Change section parser to wrap entire function in verify() for better error messages. 2020-04-05 19:21:40 -04:00
Tom Alexander
adf2f1f2b5
Move section into a DustTag as opposed to a top-level block element 2020-04-05 19:21:39 -04:00
Tom Alexander
5a0b3abf0e
Support sections with bodies 2020-04-05 19:21:39 -04:00
Tom Alexander
95a3cff278
Deriving clone/debug 2020-04-05 19:21:38 -04:00
Tom Alexander
87a7024bf0
Add tests for dust parser 2020-04-05 19:21:38 -04:00
Tom Alexander
bec69557fc
Add a definition of span and the parser for a full document 2020-04-05 19:21:37 -04:00
Tom Alexander
ac2ee2c756
Add support for filters 2020-04-05 19:21:36 -04:00
Tom Alexander
5127534609
Add a basic reference implementation missing filter support 2020-04-05 19:21:36 -04:00
Tom Alexander
9b3084856b
Starting the rust-based parser of dust templates 2020-04-05 19:21:35 -04:00
Tom Alexander
d3b58c9a0e
Add rust code to invoke the shim 2020-04-05 19:21:34 -04:00
Tom Alexander
26a752baea
Added a simple javascript "shim" to invoke dustjs for later use with testing 2020-04-05 19:21:34 -04:00
Tom Alexander
d82224ecd1
Start of a duster module 2020-04-05 19:21:34 -04:00
Tom Alexander
04fec06214
Initial commit 2020-04-05 19:21:32 -04:00