plmustache icon indicating copy to clipboard operation
plmustache copied to clipboard

Handle variables with composite types

Open steve-chavez opened this issue 2 years ago • 1 comments

Problem

Right now is not possible to get a composite type members.

Solution

Support mustache dotted names https://github.com/mustache/spec/blob/master/specs/interpolation.yml#L162-L167 like so:

create function print_person(p person) returns text as $$
Hello, {{p.name}} {{p.lastname}}
$$ language plmustache;

steve-chavez avatar Sep 08 '23 21:09 steve-chavez

It would be much easier to handle this if mustache-c sent us an array of cstrings with the dotted names..

Upstreaming a feature like that into mustache-c might be trouble because it would be a breaking change. Right now it sends dotted names as a long name.

Could be done on our fork though: https://github.com/PostgREST/mustache-c

Maybe I'll proceed with sections now, according to the spec dotted names are a shorthand for sections:

https://github.com/mustache/spec/blob/master/specs/interpolation.yml#L142-L148

steve-chavez avatar Sep 10 '23 17:09 steve-chavez