[Bese-devel] Re: strings as parameters in TAL templates

Marco Baringer mb at bese.it
Fri Feb 3 15:55:46 UTC 2006


Jan Rychter wrote:
> It doesn't, but there is clearly something I don't
> understand. inline-image generates HTML using yaclml, here is a
> narrowed-down case:


there's a bit of confusion as to what happens where and when:

the various <:blah-blah-blah macros all work by sending strings to the
yaclml:*yaclml-stream* stream, their return value is, generally, not
used. in your particular case i think the return value of inline-image
is something along the lines of "</a></div>". however tal:content (and
tal:replace) do not inline the code but send the result of the form to
yaclml:*yaclml-stream*.

in other words, <tal:tal tal:content='(inline-image "blah")'/> is
equivalent to doing:

(<:as-html (inline-image "blah"))

with the tal:escape-html="nil" it would be:

(<:as-is (inline-image "blah"))

unfortunetly inline-image sends some text to *yaclml-stream* and then
<:as-is send more text (the garbage you're getting) to the stream.
you've two options at this point:

1) use tal:lisp like so:

<tal:lisp>(inline-image "blah")</tal:lisp>

2) read the mail i just sent about defing new tal tags and do:

<my-app:inline-image filename="blah"/>

but you'll need to change inline-image to:

(defun inline-image (&key filename)
  ...

> (defun inline-image (filename)
>   (<:div :class "inline-image"
> 	 (<:a :class "inline-image"
> 	      :href "sample/image.jpg"
> 	      filename)))
> 
> This results in:
> 
> <div class="inline-image"
>   ><a class="inline-image" href="sample/image.jpg"
>     ></a
>   ></div
>> </a
>   ></div
> 
> --J.


-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen




More information about the bese-devel mailing list