Skip to content

Commit 2005b0d

Browse files
committed
fix(template): guard optional property in nested test
The optional-nested test was failing after stricter optional property checks were added. This change wraps the 'age' variable in the template with an optional guard to align with the model. Fixes #112 Signed-off-by: OmarElzero <omarmohmed7659944@gmail.com>
1 parent d25a21a commit 2005b0d

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

test/__snapshots__/TemplateMarkInterpreter.test.ts.snap

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,37 +3506,42 @@ exports[`templatemark interpreter should generate optional-nested 1`] = `
35063506
],
35073507
},
35083508
{
3509-
"$class": "org.accordproject.commonmark@0.5.0.List",
3509+
"$class": "org.accordproject.commonmark@0.5.0.Paragraph",
35103510
"nodes": [
35113511
{
3512-
"$class": "org.accordproject.commonmark@0.5.0.Item",
3512+
"$class": "org.accordproject.ciceromark@0.6.0.Optional",
3513+
"elementType": "Integer",
3514+
"hasSome": true,
3515+
"name": "age",
35133516
"nodes": [
35143517
{
3515-
"$class": "org.accordproject.commonmark@0.5.0.Paragraph",
3518+
"$class": "org.accordproject.commonmark@0.5.0.Text",
3519+
"text": "- You are ",
3520+
},
3521+
{
3522+
"$class": "org.accordproject.commonmark@0.5.0.Emph",
35163523
"nodes": [
35173524
{
3518-
"$class": "org.accordproject.commonmark@0.5.0.Text",
3519-
"text": "You are ",
3520-
},
3521-
{
3522-
"$class": "org.accordproject.commonmark@0.5.0.Emph",
3523-
"nodes": [
3524-
{
3525-
"$class": "org.accordproject.ciceromark@0.6.0.Variable",
3526-
"elementType": "Integer",
3527-
"name": "age",
3528-
"value": "42",
3529-
},
3530-
],
3531-
},
3532-
{
3533-
"$class": "org.accordproject.commonmark@0.5.0.Text",
3534-
"text": " years old",
3525+
"$class": "org.accordproject.ciceromark@0.6.0.Variable",
3526+
"elementType": "Integer",
3527+
"name": "this",
3528+
"value": "42",
35353529
},
35363530
],
35373531
},
3532+
{
3533+
"$class": "org.accordproject.commonmark@0.5.0.Text",
3534+
"text": " years old",
3535+
},
35383536
],
3537+
"whenNone": [],
3538+
"whenSome": [],
35393539
},
3540+
],
3541+
},
3542+
{
3543+
"$class": "org.accordproject.commonmark@0.5.0.List",
3544+
"nodes": [
35403545
{
35413546
"$class": "org.accordproject.commonmark@0.5.0.Item",
35423547
"nodes": [

test/templates/good/optional-nested/template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{{country}}
3737
{{/clause}}
3838

39-
- You are *{{age}}* years old
39+
{{#optional age}}- You are *{{this}}* years old{{/optional}}
4040
- Your monthly salary is {{salary as "0,0.00 CCC"}}
4141
- Your favorite colours are {{#join favoriteColors}}
4242

0 commit comments

Comments
 (0)