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: Sat, 21 Jun 2008 12:11:57 +0300	[thread overview]
Message-ID: <87od5vf8yq.fsf@moley.moleskin.org> (raw)
In-Reply-To: 49dd78620806161415u4be464a9g410073b55b581b51@mail.gmail.com

Quoth "Neil Jerram" <neiljerram@googlemail.com>:
> 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))
>> [...]
>> <unnamed port>: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





  reply	other threads:[~2008-06-21  9:11 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
2008-06-16 21:15       ` Neil Jerram
2008-06-21  9:11         ` Sebastian Tennant [this message]
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=87od5vf8yq.fsf@moley.moleskin.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).