From andy at onshored.com Mon Oct 2 18:56:07 2006 From: andy at onshored.com (Andrew Golding) Date: Mon, 02 Oct 2006 13:56:07 -0500 Subject: [html-template-devel] Additions to html-template Message-ID: <1159815367.4091.47.camel@kfreedom.onshored.com> 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. ). 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 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 at onshored.com From edi at agharta.de Wed Oct 4 10:18:42 2006 From: edi at agharta.de (Edi Weitz) Date: Wed, 04 Oct 2006 12:18:42 +0200 Subject: [html-template-devel] Additions to html-template In-Reply-To: <1159815367.4091.47.camel@kfreedom.onshored.com> (Andrew Golding's message of "Mon, 02 Oct 2006 13:56:07 -0500") References: <1159815367.4091.47.camel@kfreedom.onshored.com> Message-ID: Hi! On Mon, 02 Oct 2006 13:56:07 -0500, Andrew Golding 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. From camdez at gmail.com Sat Oct 21 16:56:31 2006 From: camdez at gmail.com (Cam Desautels) Date: Sat, 21 Oct 2006 11:56:31 -0500 Subject: [html-template-devel] Escaping of HTML in Templates Message-ID: <55738f5b0610210956r2608d149ub67c41ba7adc869e@mail.gmail.com> Forgive me if I am missing something here, but given that HTML-TEMPLATE is supposed to be agnostic to exactly what type of content I am putting in a template, why is it escaping my HTML? Is this not a bug? I'm running 0.7.0 on SBCL 0.9.16. (html-template:fill-and-print-template "

" '(:foo "This is HTML")) -->

This <em>is</em> HTML

Thanks. -- Cameron Desautels From toby at mi6.gen.nz Sat Oct 21 19:12:08 2006 From: toby at mi6.gen.nz (Toby Allsopp) Date: Sun, 22 Oct 2006 08:12:08 +1300 Subject: [html-template-devel] Re: Escaping of HTML in Templates References: <55738f5b0610210956r2608d149ub67c41ba7adc869e@mail.gmail.com> Message-ID: <87lkn9sctz.fsf@candyboy.here> "Cam Desautels" writes: > Forgive me if I am missing something here, but given that > HTML-TEMPLATE is supposed to be agnostic to exactly what type of > content I am putting in a template, why is it escaping my HTML? Is > this not a bug? I'm running 0.7.0 on SBCL 0.9.16. http://weitz.de/html-template/#*string-modifier*