(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?
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