guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scheme -> (X)HTML


From: Sebastian Tennant
Subject: Re: scheme -> (X)HTML
Date: Fri, 13 Jun 2008 20:53:22 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Neil Jerram <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]