-
Notifications
You must be signed in to change notification settings - Fork 132
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
Provide some kind of External Template Loading #36
Comments
I use this primarily in single page applications myself. In one app i even send the templates over websockets just to avoid cluttering up the app html. I agree that this is valid, the problem is, I don't think want to make the decision on how to load your templates for you. What solution would you propose? It seems like you could generate the JSON file for your app with a script and then load them as needed. I'm just not sure what ICH could do to help that. Please help me understand. |
Sounds like you are developing SPA's that are connected to the web. In that case JSON or Websockets are ok, but things become a little more messy when using your framework (which I like very much) inside an SPA running locally on the mobile device that does not connect to a web server. In this case the app is only able to run get requests against local files packaged with app. As best as I can tell, I'm only left with 3 options.
For now I'm using the following code:
Then my template files look something like: <script id="template1" type="text/html"> </script> <script id="template2" type="text/html"> </script>Maybe this is the best I can hope for, but it feels like a hack. I have talked with a few others that I know who are using your framework and we need the same thing; just a simple way to load external templates. They don't need to be dynamic, there is no reason for them to have to be encoded by an server based application. The templates just need to be scoped up with a simple get. Why would you want to "generate the JSON file for your app with a script then load them..."? Seems like unnecessary work when all that is needed is to grab a set of templates. Something simple like: ich.addExternalTemplate('/url/to/template'); would be all that would be needed in the API. The file that you load could be an HTML fragment. The format could be very simple. For example: HTML CODE HERE HTML CODE HEREIt would give people a very powerful tool to have external templates without having to create their own loader every time. |
Then my template files look something like: <html> Maybe this is the best I can hope for, but it feels like a hack. I have talked with a few others that I know who are using your framework and we need the same thing; just a simple way to load external templates. They don't need to be dynamic, there is no reason for them to have to be encoded by an server based application. The templates just need to be scoped up with a simple get. Why would you want to "generate the JSON file for your app with a script then load them..."? Seems like unnecessary work when all that is needed is to grab a set of templates. Something simple like: ich.addExternalTemplate('/url/to/template'); would be all that would be needed in the API. The file that you load could be an HTML fragment. The format could be very simple. For example: <templates> It would give people a very powerful tool to have external templates without having to create their own loader every time. ***Sorry only half of my took the first time, so I had to post in two parts. |
You could still do that: $.get('/url', function (response) {
$('template', response).each(function () {
ich.addTemplate(this.id, $(this).text());
});
}); I see no reason for ICH to make this decision for you. |
As this can be done any number of ways, I'd prefer not to make that decision. Closing for now. |
Hi Henrik,
I had posted this as a comment to a closed post, but thought I would open it as it's own post.
I understand that you don't want to push people in one direction or another with respect to remote template loading, but there might be a bigger picture here that you should consider. For example what about those of us using your framework on mobile phones. In frameworks like phonegap it is a benefit to have the whole app be a single page. In my case I end up with a index.html page with 50+ templates in it. My app does not connect to a server so I can point to a local json file that I have to encode by hand (manually embedding HTML in json sucks!). It works, but it is not pretty. It would be much easier if the framework allowed me to point to a files that included all of my templates in pure text format. This way I could put all 50+ in one file, or break them up by module.
I'm not saying I like the current proposed solutions for remote loading, but I think something that takes us SPI (http://en.wikipedia.org/wiki/Single-page_application) and SPI standalone and mobile developer into consideration would be nice.
Just my 2 cents...
The text was updated successfully, but these errors were encountered: