From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Tennant Newsgroups: gmane.lisp.guile.user Subject: Re: scheme -> (X)HTML Date: Sat, 21 Jun 2008 12:11:57 +0300 Message-ID: <87od5vf8yq.fsf@moley.moleskin.org> References: <20080325193702.6B6AE94049@webmail220.herald.ox.ac.uk> <2bc5f8210803251253p6f07911brcceaa1cc2bf949c1@mail.gmail.com> <87bq521qu6.fsf@ossau.uklinux.net> <3anht5tp.fsf@vps203.linuxvps.org> <49dd78620806161415u4be464a9g410073b55b581b51@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214039552 20169 80.91.229.12 (21 Jun 2008 09:12:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Jun 2008 09:12:32 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jun 21 11:13:17 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K9z9i-00066B-Hn for guile-user@m.gmane.org; Sat, 21 Jun 2008 11:13:10 +0200 Original-Received: from localhost ([127.0.0.1]:42834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9z8t-0002oM-HM for guile-user@m.gmane.org; Sat, 21 Jun 2008 05:12:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K9z8n-0002nB-Gl for guile-user@gnu.org; Sat, 21 Jun 2008 05:12:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K9z8m-0002lw-1N for guile-user@gnu.org; Sat, 21 Jun 2008 05:12:12 -0400 Original-Received: from [199.232.76.173] (port=58669 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9z8l-0002lj-Q3 for guile-user@gnu.org; Sat, 21 Jun 2008 05:12:11 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:42996 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K9z8l-0003Lz-F5 for guile-user@gnu.org; Sat, 21 Jun 2008 05:12:11 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K9z8g-0005X8-MA for guile-user@gnu.org; Sat, 21 Jun 2008 09:12:06 +0000 Original-Received: from 85.105.17.65 ([85.105.17.65]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Jun 2008 09:12:06 +0000 Original-Received: from sebyte by 85.105.17.65 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 21 Jun 2008 09:12:06 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 75 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 85.105.17.65 User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:AxIISFgBo6K/MDMMT9A2Iwz8IvU= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6612 Archived-At: Quoth "Neil Jerram" : > OK, I've checked now, and it appears that the code already posted is > the most up to date that I have. Noted. >> guile> (process-template "/path/to/version.html" ((foo 'bar)) (ice-9 rdelim)) >> [...] >> :1:1: Unbound variable: begin >> ABORT: (unbound-variable) > The process-template call is just slightly wrong; it just needs to > mention the (guile) module also [...as] the (guile) module contains > Guile's core bindings, including `begin'. Ah, I see. I suspected this but make-module is not included in the procedure index of the info manual and nowhere is there any mention of the (guile) module. > (Possibly process-template could add (guile) automatically, but the > implementation as it stands allows for greater precision.) Absolutely, and it's not hard to use once you know how. >> Would it not suffice to evaluate the template code in the environment >> of the CGI script, i.e., with all the modules loaded and required >> variables defined in the script before >> >> (eval-string (template-code "/path/to/more-complex-template.html")) >> >> is called? > Interesting idea. I didn't provide that option before, because it > wasn't helpful in the context of the program for which I wrote (ossau > template), but you can easily define another API, say `eval-template', > which does this: > > (define (eval-template template . module) > (eval (with-input-from-string (template->code template) read) > (if (null? module) (current-module) (car module)))) > > Then the call would be just (eval-template "/path/to/more-complex-template.html"). Neat. > (The thing with process-template is that it allows additional variable > bindings to be set up for just that process-template call, and one > wouldn't (I think) want those bindings to persist in the whatever is > the reference module for the template code. So process-template > currently creates a temporary module, using make-module, to avoid > this. But this is not cast in stone; perhaps process-template should > use a surrounding `let' form instead to set up the bindings, or > perhaps it would be better for the template file to begin with > > $(use-modules (ice-9 rdelim))$ > > instead of having (ice-9 rdelim) in the process-template call. I'm not sure.) So many options, so few clinchers. >> Could you perhaps provide a simple example usage of process-template? > I do have more examples, but I think this is probably already covered > above; let me know if not. Your explanation is crystal clear, thanks a lot. I was going to suggest modifying process-template to accept an empty variables list and, in the absence of a module list, use (guile) and the (current-module) used, but eval-template is much cleaner. Out of pure curiosity, whats the significance of '31' in the make-module call in process-template? Seb -- Emacs' AlsaPlayer - Music Without Jolts http://sebyte.org/eap.html