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: Fri, 13 Jun 2008 20:53:22 +0000 Message-ID: <3anht5tp.fsf@vps203.linuxvps.org> References: <20080325193702.6B6AE94049@webmail220.herald.ox.ac.uk> <2bc5f8210803251253p6f07911brcceaa1cc2bf949c1@mail.gmail.com> <87bq521qu6.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213390443 16743 80.91.229.12 (13 Jun 2008 20:54:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Jun 2008 20:54:03 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jun 13 22:54:46 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 1K7GI9-0000ah-Ib for guile-user@m.gmane.org; Fri, 13 Jun 2008 22:54:37 +0200 Original-Received: from localhost ([127.0.0.1]:36613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7GHL-0002nw-Mh for guile-user@m.gmane.org; Fri, 13 Jun 2008 16:53:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7GHG-0002n1-Cp for guile-user@gnu.org; Fri, 13 Jun 2008 16:53:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7GHE-0002mp-TT for guile-user@gnu.org; Fri, 13 Jun 2008 16:53:41 -0400 Original-Received: from [199.232.76.173] (port=46871 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7GHE-0002mm-OX for guile-user@gnu.org; Fri, 13 Jun 2008 16:53:40 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:60271 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 1K7GHE-0002N1-5k for guile-user@gnu.org; Fri, 13 Jun 2008 16:53:40 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K7GH7-0004ra-Jd for guile-user@gnu.org; Fri, 13 Jun 2008 20:53:33 +0000 Original-Received: from vps203.linuxvps.org ([91.186.7.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Jun 2008 20:53:33 +0000 Original-Received: from sebyte by vps203.linuxvps.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Jun 2008 20:53:33 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: vps203.linuxvps.org User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:M0KR76tHgFQbQmdDqDHQeS+F6c0= 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:6610 Archived-At: Neil Jerram writes: > As a further option, please see attached [template.scm]. If you're > interested in this, please let me know, because I may have a more up > to date version somewhere. I'd be interested in getting hold of the latest version of template.scm as it does exactly what I need for my Guile CGI scripting projects. Also, how to use the process-template macro? Having created the file version.html which reads:

This page was processed by Guile $(display (version))$

I can get the desired result in a REPL using primitive-eval: guile> (primitive-eval (with-input-from-string (template->code "/path/to/version.html") read))

This page was processed by Guile 1.8.4

guile> or, better still, using eval-string: guile> (eval-string (template->code "/path/to/version.html"))

This page was processed by Guile 1.8.4

guile> but using the process-template macro (with a variable list and module requirement) produces an error: guile> (process-template "/path/to/version.html" ((foo 'bar)) (ice-9 rdelim)) Backtrace: In standard input: 39: 0* (process-template "/path/to/version.html" ((foo (quote bar))) ...) 39: 1 (let* ((module #)) (module-define! module (quote foo) ...) ...) In unknown file: ?: 2 [eval (begin # # # ...) #] 1: 3* (begin # # # ...) :1:1: In expression (begin (display " ") (display "

This page was processed by Guile ") ...): :1:1: Unbound variable: begin ABORT: (unbound-variable) 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? Could you perhaps provide a simple example usage of process-template? Any guidance much appreciated. Regards, Sebastian