You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
sunnysonx
changed the title
Support for nested objects inside template builder.
[Feature request] Support for nested objects inside template builder.
Jan 7, 2021
Feature request
Please describe your feature request
Add support for nested objects inside the template builder.
Example
Why is it needed?
Suggested solution(s)
_.get(page,'menu_item.slug')
will return the homepageThe text was updated successfully, but these errors were encountered: