Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue referencing @key after #with #592

Open
HectorCastelli opened this issue Jul 4, 2023 · 1 comment
Open

Issue referencing @key after #with #592

HectorCastelli opened this issue Jul 4, 2023 · 1 comment

Comments

@HectorCastelli
Copy link

Hello! First of all, thanks a lot for your hard work on this library!

Issue Description

I have found a case where the library behaves differently than handlebars.js:

Here is the setup:

Template

# {{data.name}}

{{#each data.related as |related|}}
{{#with (lookup ../other.contents @key) as | other_related |}}
## [{{other_related.name}}](/{{@key}})
{{related.relationship}}
{{/with}}
{{/each}}

Data

{
    "data": {
        "name": "John",
        "related": {
            "mary": {
                "relationship": "Siblings"
            }
        }
    },
    "other": {
        "contents": {
            "john": {
                "name": "John",
                "related": {
                    "mary": {
                        "relationship": "Siblings"
                    }
                }
            },
            "mary": {
                "name": "Mary"
            }
        }
    }
}

Expected output

# John

## [Mary](/mary)
Siblings

Actual output

# John

## [Mary](/)
Siblings

This is a link to the handlebars' playground showing what I am attempting to do: here.

This is a link to a repository that can be cloned to reproduce the issue: here.

Further notes

The main issue seems to be referencing @key inside a {{#with}} block.

Do you have any insights on why this is the case, if there is a setting I overlooked in the library, or if there are workarounds?

I am more than happy to help, albeit a little bad inexperienced with rust.

Thanks in advance!

@sunng87
Copy link
Owner

sunng87 commented Jul 5, 2023

It seems there is an incompatible path resolution with with block. In handlebars-rust, you can use {{@../key}} to get mary. I will look into this issue and try to fix it on 5.0 release channel.

HectorCastelli added a commit to powerd6-old/core-rules that referenced this issue Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants