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: Sat, 21 Jun 2008 12:11:57 +0300
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.2 (gnu/linux)

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

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