Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: resolve parameters in Page.url #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Blazing fast Apple TV application development using pure JavaScript.
- [Custom options while navigation](#custom-options-while-navigation)
- [Creating Menu Page](#creating-menu-page)
- [Application initialization using configuration](#application-initialization-using-configuration)
- [Dynamic Page URLs](#dynamic-page-urls)
- [Sample Code](#sample-code)
- [Useful Links](#useful-links)
- [Contributions](#contributions)
Expand Down Expand Up @@ -430,6 +431,25 @@ ATV.start({
});
```

<a name="dynamic-page-urls"></a>
#### Dynamic Page URLs

You can use express-style path-variables in `url`. The example below will resolve `:param` with `"value"`.
**Note that all defined parameters (i.e. every string in the `url` starting with a `:`) must be set in `urlParams`!**

```javascript
ATV.Page.create({
name: 'home',
url: 'path/to/your/api/that/returns/json?param=:param',
template: your_template_function
});
```
```
<button data-href-page="login" data-href-page-options='{"urlParams": {"param": "value"}}'>
<text>Login</text>
</button>
```

<a name="sample-code"></a>
### Sample Code
You can find a port of the original TVML Catalog sample code [re-written using atvjs](https://github.com/emadalam/tvml-catalog-using-atvjs).
Expand Down