pogonos icon indicating copy to clipboard operation
pogonos copied to clipboard

Fully qualified keyword is not rendered in lambdas

Open liquidz opened this issue 3 years ago • 2 comments

Expected

(pg/render-string "{{#f}}{{a/b}}{{/f}}" {:f #(str % " world")
                                         :a/b "hello"})
;; => "hello world"

Actual

(pg/render-string "{{#f}}{{a/b}}{{/f}}" {:f #(str % " world")
                                         :a/b "hello"})
;; => " world"

while (pg/render-string "{{#f}}{{foo}}{{/f}}" {:f #(str % " world") :foo "hello"}) returns "hello world"

liquidz avatar Jul 17 '22 20:07 liquidz

Thank you for reporting!

I'll look into it later, but I don't clearly remember if Pogonos was trying to fully support qualified keywords. Also, I'm curious about how ambiguous keys like {{a.b/c.d}} should be interpreted. Should it be interpreted as equivalent to:

{{#a}}{{#b/c}}{{d}}{{/b/c}}{{/a}}

Or:

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

where a.b/c is a key qualified with the namespace a.b? (Or should it be taken as an atomic key a.b/c.d that can't be divided into smaller parts?) Do you have any thoughts on this?

athos avatar Jul 19 '22 05:07 athos

Thanks for your confirmation!

Oh I forgot about dotted names... It seems impossible to fully support fully qualified keyword since it cannot be interpreted uniquely.

In my opinion, fully qualified keyword is outside the specification of mustache, so dotted names should have priority. Thus, if we support fully qualified keyword partially, {{a.b/c}} should be parsed to {{#a}}{{b/c}}{{/a}}.

liquidz avatar Jul 19 '22 22:07 liquidz