Hello to all the members of this list.
Recently at Onshore Development, we have started using HTML-TEMPLATE to render web-pages in an application we call Woofie, which provides an alternative interface to Webcheckout.
While working on html templates for Woofie, I found myself wanting some extra abilities currently not available in HTML-TEMPLATE, mainly a foreach style loop with the variable which holds the current value of the list declared inside the tag, and the ability to use certain lisp expressions (format inside tmpl-var's and equality comparisons, boolean comparisons (or, and, etc.) inside of tmpl-if's).
I would like to see if other developers would find such features useful. I currently have implemented both features I described to some degree in the following fashion:
- the for-each style loop is represented in my templates as TMPL_LOOP_FOR and closed with a /TMPL_LOOP. The tag looks for two separate strings, one being the variable and the other being the list (eg. <!-- TMPL_LOOP_FOR author authors -->). In the code, in each iteration of the loop over authors, a (setf (getf values :author) author) is performed (this should probably be changed into something similar to the *value-access-function*, or the perhaps *value-access-function* could be made setf'able?).
- TMPL_IF and TMPL_VAR can take a symbol or a list. The list is deserialized from a string into a list of symbols or string literals delimited by double quotes. A larger expression is built by making a let, then evaluating the list. For example, the format expression in <!-- TMPL_VAR (format nil "Displaying ~d results, displaying ~d through ~d." result-count first-result last-result) --> would get expanded to:
(let ((result-count (funcall *value-access-function* :result-count values)) (first-result (funcall *value-access-function* :first-result values)) (last-result (funcall *value-access-function* :last-result values))) (format nil "Displaying ~d results, displaying ~d through ~d." result-count first-result last-result)), which passed to (eval) and currently evaluated in the common lisp package (though evaluation should probably get done in some user-specified package that can be made to contain helper-functions for displaying data).
I would appreciate any comments, and I will try to answer any questions should there be any (I'm guessing there will). The code can be found at http://kfreedom.onshored.com/html-template-additions.lisp , and should work with the standard html-template 0.7.0 package.
Regards, Andrew Golding andy@onshored.com
Hi!
On Mon, 02 Oct 2006 13:56:07 -0500, Andrew Golding andy@onshored.com wrote:
Recently at Onshore Development, we have started using HTML-TEMPLATE to render web-pages in an application we call Woofie, which provides an alternative interface to Webcheckout.
While working on html templates for Woofie, I found myself wanting some extra abilities currently not available in HTML-TEMPLATE, mainly a foreach style loop with the variable which holds the current value of the list declared inside the tag, and the ability to use certain lisp expressions (format inside tmpl-var's and equality comparisons, boolean comparisons (or, and, etc.) inside of tmpl-if's).
I would like to see if other developers would find such features useful.
[...]
I would appreciate any comments, and I will try to answer any questions should there be any (I'm guessing there will). The code can be found at http://kfreedom.onshored.com/html-template-additions.lisp , and should work with the standard html-template 0.7.0 package.
I understand how this can be useful, but I wouldn't want to add it to the HTML-TEMPLATE main code base, because I think it doesn't fit with the original goal (borrowed from the Perl role model) of extreme simplicity without mixing code and data. Also, I'm always a bit skeptical if EVAL is involved.
If you don't want to fork HTML-TEMPLATE, I can offer to add your code to a "contrib" directoy within the HTML-TEMPLATE distribution to which you can add the necessary documentation. Would that be OK for you?
Cheers, Edi.
Hello folks,
"Andrew Golding" andy@onshored.com wrote:
AG> Recently at Onshore Development, we have started using AG> HTML-TEMPLATE to render web-pages in an application we call Woofie, AG> which provides an alternative interface to Webcheckout. AG> |...snip...| AG> I would appreciate any comments, and I will try to answer any AG> questions should there be any (I'm guessing there will). The code AG> can be found at AG> http://kfreedom.onshored.com/html-template-additions.lisp , and should work with AG> the standard html-template 0.7.0 package.
Some of those suggestions look valueable to me though they are a bit old. Unfortunately, Andrew's page is not available now, and he has not replied to my private e-mail.
Has anybody saved (a version of) the mentioned code? -- Sincerely, Dmitriy Ivanov lisp.ystok.ru
On Tue, 22 Apr 2008 09:59:49 +0400, "Dmitriy Ivanov" divanov@aha.ru wrote:
Some of those suggestions look valueable to me
Was the mail you're replying to sent to the list? I didn't see it.
"Edi Weitz" edi@agharta.de wrote:
EW> Was the mail you're replying to sent to the list? I didn't see EW> it.
Yes. It was dated as of 2006-10-02 and is kept in gmane along with your answer as of 2006-10-04. -- Sincerely, Dmitriy Ivanov lisp.ystok.ru
On Tue, 22 Apr 2008 11:10:19 +0400, "Dmitriy Ivanov" divanov@aha.ru wrote:
Yes. It was dated as of 2006-10-02 and is kept in gmane along with your answer as of 2006-10-04.
Ah, OK. That's a /very/ old one then... :)
html-template-devel@common-lisp.net