patspam
28 May 2007, 11:16 PM
I normally get a designer to skin my webapps using a templating language such as Perl's HTML::Template (http://search.cpan.org/~samtregar/HTML-Template-2.9/Template.pm). which allows the designer to skin my site without seeing or understanding any of my code. It doesn't have any of the cool Ext.Template formatting functions but it does let you do simple If/Else and Looping. I'd really like to achieve the same sort of thing using Ext.Template but I'm not quite sure how to go about doing it.
For example I have a simple web service that returns a list of search results.
The HTML::Template way is to use HTML::Template on the server to return a formatted HTML string from the web service.
Say I change my web service to return JSON data. Ext.JsonView lets me very easily combine the json data and a template to get the equivalent formatted HTML, but how can I move the Template out of my javascript code into a separate file so that my designer can skin my site without getting lost in code?
They can skin an individual search result item:
'<li id="{id}">{foo} - {bar}</li>'
But what about the content before/after all of the list items? Do I have to get them to provide separate template strings for each of these, as well as separate template string for error conditions etc..? The problem is that the looping logic is in my code and not in the template.
There's also the question of where you actually put these template strings, do you embed them in hidden DIVs etc.. I found this post (http://extjs.com/forum/showthread.php?t=581&highlight=template+looping) which suggests that embedded templates in HTML would not be a good idea.
I'm just starting to come to grips to ext so apologies if there's a good way to do this already.
Thanks,
Patrick
For example I have a simple web service that returns a list of search results.
The HTML::Template way is to use HTML::Template on the server to return a formatted HTML string from the web service.
Say I change my web service to return JSON data. Ext.JsonView lets me very easily combine the json data and a template to get the equivalent formatted HTML, but how can I move the Template out of my javascript code into a separate file so that my designer can skin my site without getting lost in code?
They can skin an individual search result item:
'<li id="{id}">{foo} - {bar}</li>'
But what about the content before/after all of the list items? Do I have to get them to provide separate template strings for each of these, as well as separate template string for error conditions etc..? The problem is that the looping logic is in my code and not in the template.
There's also the question of where you actually put these template strings, do you embed them in hidden DIVs etc.. I found this post (http://extjs.com/forum/showthread.php?t=581&highlight=template+looping) which suggests that embedded templates in HTML would not be a good idea.
I'm just starting to come to grips to ext so apologies if there's a good way to do this already.
Thanks,
Patrick