From: Sard
Subject: HTML-TEMPLATE confusion
Date: 
Message-ID: <1185138396.846757.167720@m3g2000hsh.googlegroups.com>
(require 'html-template)
(defparameter my-str "Hello")
(defparameter my-template "<!-- TMPL_VAR foo -->")
(let ((tp (html-template:create-template-printer my-template)))
  (html-template:fill-and-print-template tp '(:foo my-str)))

Prints my-str instead of Hello.  The my-str symbol doesn't seem to be
evaluated.  What am I missing?

From: Joshua Taylor
Subject: Re: HTML-TEMPLATE confusion
Date: 
Message-ID: <1185141482.290748.253220@w3g2000hsg.googlegroups.com>
On Jul 22, 5:06 pm, Sard <··········@gmail.com> wrote:
> (require 'html-template)
> (defparameter my-str "Hello")
> (defparameter my-template "<!-- TMPL_VAR foo -->")
> (let ((tp (html-template:create-template-printer my-template)))
>   (html-template:fill-and-print-template tp '(:foo my-str)))
>
> Prints my-str instead of Hello.  The my-str symbol doesn't seem to be
> evaluated.  What am I missing?

I don't know anything about HTML-TEMPLATE, so I can't tell you whether
you're using it correctly or not, but you're calling html-
template:fill-and-print-template with the value of the variable tp and
a list of two symbols, the first of which is :foo and the second of
which is my-str. This happens because you're quoting your list. You
probably want:

(html-template:fill-and-print-template tp (list :foo my-str))

which makes it clear that you're making a list of two values, the
first of which is the symbol :foo, and the second of which is the
value of the variable my-str. Alternatively, you can use the backquote
syntax (which, if you're going to be using longer arguments, might be
more convenient):

(html-template:fill-and-print-template tp `(:foo ,my-str)).

If you're not familiar with the backquote syntax, you can read more
about it at http://www.lisp.org/HyperSpec/Body/sec_2-4-6.html. One of
the examples from that page (which is probably enough to explain the
above) is:

"The backquote introduces a template of a data structure to be built.
For example, writing
 `(cond ((numberp ,x) ,@y) (t (print ,x) ,@y))

is roughly equivalent to writing

 (list 'cond
       (cons (list 'numberp x) y)
       (list* 't (list 'print x) y))"


Hope this help,
//J
From: Chaitanya Gupta
Subject: Re: HTML-TEMPLATE confusion
Date: 
Message-ID: <f81k9t$2k8$1@registered.motzarella.org>
Sard wrote:
> (require 'html-template)
> (defparameter my-str "Hello")
> (defparameter my-template "<!-- TMPL_VAR foo -->")
> (let ((tp (html-template:create-template-printer my-template)))
>   (html-template:fill-and-print-template tp '(:foo my-str)))
> 
> Prints my-str instead of Hello.  The my-str symbol doesn't seem to be
> evaluated.  What am I missing?
> 

See QUOTE(1) and LIST(2).

Chaitanya


1. http://www.lispworks.com/documentation/HyperSpec/Body/s_quote.htm#quote

2. http://www.lispworks.com/documentation/HyperSpec/Body/f_list_.htm#listST