geraintluff / uri-templates

JavaScript utility for RFC 6570: URI Templates
138 stars 21 forks source link

Expand nested objects #22

Open heruan opened 8 years ago

heruan commented 8 years ago

Is it possible to do something like this?

const params = {
    user: {
        id: 123
    }
};

template("/users/{user.id}").fill(params); // => "/users/123"
nichtich commented 6 years ago

The specification says:

Structures are processed as if they are an associative array with names corresponding to the fields in the structure definition and "." separators used to indicate name hierarchy in substructures

So your example must be expanded to "/users/123"