-
Notifications
You must be signed in to change notification settings - Fork 475
Open
Description
Feature request
Please describe your feature request
Add support for nested objects inside the template builder.
Example
let page = {
"id": "1",
"page_title": "My test page",
"page_body": "some text here",
"page_slug":"my-test-page",
"menu_item":{
"name":"Homepage",
"slug":"homepage"
}
}
let template = new URITemplate("http://example.org/{menu_item.slug}/{page_slug}");
let result = template.expand(page);
// result = http://example.org/homepage/my-test-page
Why is it needed?
- Because it's nice to have such a feature, simplifies things.
- Avoids the necessity to manually expand the template and allows you to directly provide the object.
Suggested solution(s)
- A solution would be to use the same approach as lodash uses for get() https://lodash.com/docs/4.17.15#get, as it returns the value based on the path, for current example,
_.get(page,'menu_item.slug')
will return the homepage
Metadata
Metadata
Assignees
Labels
No labels