Mustache.jl icon indicating copy to clipboard operation
Mustache.jl copied to clipboard

(Not indefinitely) Recursive partials templates fail to parse

Open Kissaki opened this issue 6 years ago • 9 comments

I created a minimal test file pair in https://github.com/Kissaki/Mustache.jl/commit/d56e7fca783216de10eb1560c9ff27540ff6d8f8

The parsing takes a while, but then returns nothing.

Instead, I would expect the partial to include itself until the child element does not exist anymore, at which point it continues returning from the recursion.

Kissaki avatar Nov 01 '18 21:11 Kissaki

I ran into another issue that sheds some light. It looks like sections ({{#child}}) do not actually get the section context but instead retain the partial root context.

This seems to not be an issue on the first partial, but on the partial included by the partial. Hence, the context will not change to the child anymore, hence an endless recursion.

Kissaki avatar Nov 01 '18 23:11 Kissaki

Thx. I’ll have a look.

jverzani avatar Nov 02 '18 01:11 jverzani

Thanks again! I think this will address the issue appropriately. I limit the context that a partial is evaluated within, before it was the immediate context and its parent, so in your example y would always resolve within the parent, now it won't. This doesn't break the spec tests, so hopefully won't break anything you are otherwise doing, but do let me know if it does.

jverzani avatar Nov 03 '18 15:11 jverzani

Do you want me to test that PR or something?

I don't know how I would use and test a library locally that I otherwise get via package manager.

Kissaki avatar Nov 03 '18 15:11 Kissaki

It passes your test, but if you have something more involved you can dev a branch of a package pretty easily. Something like dev pkg#branch.

On Sat, Nov 3, 2018 at 11:31 AM Jan Klass [email protected] wrote:

Do you want me to test that PR or something?

I don't know how I would use and test a library locally that I otherwise get via package manager.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/jverzani/Mustache.jl/issues/82#issuecomment-435596581, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZvTODG4pgYCQA69yCsNRymioV1z2-Yks5urbbDgaJpZM4YJlyz .

-- John Verzani Department of Mathematics College of Staten Island, CUNY [email protected]

jverzani avatar Nov 03 '18 16:11 jverzani

I don’t have anything more involved.

Kissaki avatar Nov 03 '18 18:11 Kissaki

Okay. I’ll merge. If there are issues it can be rethought. Thanks again.

On Sat, Nov 3, 2018 at 2:12 PM Jan Klass [email protected] wrote:

I don’t have anything more involved.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/jverzani/Mustache.jl/issues/82#issuecomment-435609252, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZvTCOBmLLBv4wnj9s5doaBxqAhwXh_ks5urdyigaJpZM4YJlyz .

-- John Verzani Department of Mathematics College of Staten Island, CUNY [email protected]

jverzani avatar Nov 03 '18 18:11 jverzani

Should I create a new ticket?

I have a problem using recursive partials still. In my program it fails to pass on the context. I have difficulties reproducing it in a minimal setup. But what I could reproduce:

https://github.com/Kissaki/Mustache.jl/commit/917a34e74963c228933687f5473e2bb97968491b

{{.}} does not print anything in the second-level partial, but outside of it it dies.

The produced output:

Info: a
│     Outside: Dict("x"=>"b")
│     Inside:
│     b
│     Outside: Dict("x"=>"c")
│     Inside:
└     c

Kissaki avatar Nov 04 '18 11:11 Kissaki

Thank you for the fixes. At least for my use case, it seems to work for multi-level-recursed partials.

Kissaki avatar Nov 10 '18 00:11 Kissaki