-
Notifications
You must be signed in to change notification settings - Fork 31
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
Idea: data key to id convention #18
Comments
@ebryn, what do you think of this? |
What happens if you have the same value in multiple places? |
Combined with another idea, this can be very elegantly taken care of. Other idea is... embed api endpoints in the handlebars template, looks like: <ul>
{{ /friends/list }}
<li>{{ this.name }}</li>
{{ /}}
</ul> Then, you scope by api endpoint. The endpoint url can prefix the names, that is |
But if you actually have the same value in two places obviously we want to update both. |
@tomdale I think this could really make handlebars shine, especially on the server side A classic problem I think with logic-less templates server side is specifying where the data should come from. Client side apps specify the api endpoints for their data, not the backend. To get the fastest page loads, this is the cleanest api I can think of. Block helpers are a tricky one, but let's leave that to a separate discussion. |
Basically, instead of generating script tag markers with mostly arbitrary numbers, have them be a stringification of the data keys. For example:
Sample json:
Render with template:
Produces:
This moves towards having an initial state rendered server side, as @tomdale just mentioned in a talk tonight.
When you get an update of this json:
There's a simple convention to update the page. Here's a very rough outline of the code:
For arrays, my best idea is to embed the indices into the id's.
The text was updated successfully, but these errors were encountered: