Handlebars.js
Remake uses Handlebars.js to render every template. All templates are server-rendered.
Template Variables
These are all the possible template variables you'll have access to in a Handlebars template:
- Your app's data
- On routes preceded by a username, e.g.
/johnor/john/tasks, all of the data for that user is loaded into the template and made available
- On routes preceded by a username, e.g.
- globalData
- This is static data shared by all templates and all users (loaded from the file
app/data/global-app-data.json). It's useful for defining global navigation items or page titles you want to use across all users.
- This is static data shared by all templates and all users (loaded from the file
- params
- These are the url parameters. For example, you can get the username, the pageName, the itemId from here.
- query
- This is an object with the all the query parameters in the url.
- pathname
- This is the current url's pathname.
- currentItem
- If you're at a route like
/john/tasks/3456, this will be the item in john's data that matches the id3456. If no item matching this id is found or you're not at that type of route, this variable will beundefined.
- If you're at a route like
- parentItem
- This is the object that's above
currentItemin the data. This is useful if you are letting the user browse their data hierarchically and you need to go up a level to the previous item.
- This is the object that's above
- flashErrors
- If there are any errors from the previous interaction (e.g. wrong password when signing in), they'll be stored in this array so they can be displayed on the page.
- flashSuccesses
- If there are any success messages from the previous interaction, they'll be stored in this array so they can be displayed on the page.
- currentUser
- This is an object with the current user's details in it. You can find their username like this:
currentUser.details.usernameand their app data like this:currentUser.appData.
- This is an object with the current user's details in it. You can find their username like this:
- pageAuthor
- This is available only if you're at route like
/johnor/kate, with a username in it. If you are, this variable will contain the data of user that matches this username. It may be equal to the currentUser.
- This is available only if you're at route like
- isPageAuthor
- This is true if the currentUser is also the pageAuthor.
- pageHasAppData
- This is true if you're on a page like
/johnor/kate. Data is loaded from their JSON file database, so it's available on this page. If there's apageAuthorvariable, this will be set totrue.
- This is true if you're on a page like
Extra helpers
Remake also ships with all 188 Handlebars Helpers, so you can have lots of flexibility with how you render your data.