soasme / nim-mustache

Mustache in Nim

Home Page:https://mustache.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

some failures against latest specs

pietroppeter opened this issue · comments

I made a document that shows the output of nim-mustache against the specs and I used the latest specs. Here is the document which shows some failures: https://pietroppeter.github.io/nblog/drafts/mustache_specs.html

The failures are due to changes in the latest releases (v1.2.0 of 9 days ago and v1.2.1 of 4 days ago) that introduced additional tests for existing features.

Here are the name of failing tests:

  • from interpolation.json:
    • Dotted Names - Context Precedence
    • Implicit Iterators - Basic Interpolation
    • Implicit Iterators - HTML Escaping
    • Implicit Iterators - Triple Mustache
    • Implicit Iterators - Ampersand
    • Implicit Iterators - Basic Integer Interpolation
  • from sections.json:
    • Variable test
    • Deeply Nested Contexts

The tests with names starting with Implicit Iterators are failures in the sense that the spec uses a data json that is not an object. The Context of nim-mustache must have as values field a table. Probably a fix would require to change the type of values to be a Value itself (and rename it to value)?

For the other 3 failing tests I report here for convenience the data with expected output and output from nim-mustache.

❌ Dotted Names - Context Precedence

Dotted names should be resolved against former resolutions.

Template:

{{#a}}{{b.c}}{{/a}}

Data:

{"a":{"b":{}},"b":{"c":"ERROR"}}

Expected:

Output:

ERROR

❌ Variable test

Non-false sections have their value at the top of context, accessible as {{.}} or through the parent context. This gives a simple way to display content conditionally if a variable exists.

Template:

"{{#foo}}{{.}} is {{foo}}{{/foo}}"

Data:

{"foo":"bar"}

Expected:

"bar is bar"

Output:

" is bar"

❌ Deeply Nested Contexts

All elements on the context stack should be accessible.

Template:

{{#a}}
{{one}}
{{#b}}
{{one}}{{two}}{{one}}
{{#c}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{#d}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{#five}}
{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
{{one}}{{two}}{{three}}{{four}}{{.}}6{{.}}{{four}}{{three}}{{two}}{{one}}
{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
{{/five}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{/d}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{/c}}
{{one}}{{two}}{{one}}
{{/b}}
{{one}}
{{/a}}

Data:

{"a":{"one":1},"b":{"two":2},"c":{"three":3,"d":{"four":4,"five":5}}}

Expected:

1
121
12321
1234321
123454321
12345654321
123454321
1234321
12321
121
1

Output:

1
121
12321
1234321
123454321
123464321
123454321
1234321
12321
121
1
commented

Thanks for the reporting. I'll spend some time reading the new spec and see how to adapt to it.

commented

@pietroppeter I have released v0.4.0, which should fix all the failed test cases reported in this issue. Please let me know if it solves your problem.

Great job! I will run again and let you know!