unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Sebastian Tennant <sebyte@smolny.plus.com>
To: guile-user@gnu.org
Subject: Re: scheme -> (X)HTML
Date: Fri, 13 Jun 2008 20:53:22 +0000	[thread overview]
Message-ID: <3anht5tp.fsf@vps203.linuxvps.org> (raw)
In-Reply-To: 87bq521qu6.fsf@ossau.uklinux.net

Neil Jerram <neil@ossau.uklinux.net> 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:

  <html>
   <p>This page was processed by Guile $(display (version))$</p>
  </html>

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))
  <html>
    <p>This page was processed by Guile 1.8.4</p>
  </html>
  guile>

or, better still, using eval-string:

  guile> (eval-string (template->code "/path/to/version.html"))
  <html>
    <p>This page was processed by Guile 1.8.4</p>
  </html>
  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 # # # ...) #<module b7cca530>]
     1: 3* (begin # # # ...)

  <unnamed port>:1:1: In expression (begin (display "<html>
  ") (display "  <p>This page was processed by Guile ") ...):
  <unnamed port>: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





  reply	other threads:[~2008-06-13 20:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 19:37 scheme -> (X)HTML Paul Emsley
2008-03-25 19:53 ` Julian Graham
2008-03-25 20:38   ` Neil Jerram
2008-06-13 20:53     ` Sebastian Tennant [this message]
2008-06-16 21:15       ` Neil Jerram
2008-06-21  9:11         ` Sebastian Tennant
2008-07-03 22:32           ` Neil Jerram
2008-03-31 16:41   ` Paul Emsley
2008-03-31 20:33     ` Francesco Salvestrini
2008-04-02 11:42       ` Thien-Thi Nguyen
2008-03-25 20:49 ` Francesco Salvestrini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3anht5tp.fsf@vps203.linuxvps.org \
    --to=sebyte@smolny.plus.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).