[Bese-devel] How to use tal-templates
Marco Simon
marco_simon at web.de
Mon Aug 15 08:25:04 UTC 2005
Hi William,
I fear I didn't explain correctly what's my need.
Perhaps I should tell what I wanna do:
I want to embed some html or js snippets directly into
my ucw-code. (something like
(<:as-is code_snippet)
An easy example would be:
(<:as-is "<script type=\"text/javascript\"> alert(\"Hello
World\")</script)")
As you can see I had to escape several double-quotation-marks in order to
make lisp handle this as one Sting. This "escaping by hand" might be ok for
short and handwritten snippets, but if I've got some longer js-code with
lots
of " in it, it will become some work to escape all all of them " by hand
(if even possible).
This is why I'am looking for some function which escapes all " within
that snipped.
In php I'd easyly write someting like this:
<? echo addslashes($snipped) ?> or
<? $mysnipped = '<script type="text/javascript"> alert ("Hello World")
</script>' ?>
I'm absolutely sure that something similar is even possible with lisp,
but I didn't
realize how to do so far.
Thanks for your hints,
best regards
Marco
William Halliburton schrieb:
>Ok. Here is an answer the second part.
>
>(defun escape-char (char str)
> "Return string with CHAR escaped in string STR with #\\"
> (with-output-to-string (s)
> (loop
> for c across str
> do (cond
> ((char= c char)
> (write-char #\\ s)
> (write-char c s))
> (t (write-char c s))))))
>
>On 8/14/05, Marco Simon <marco_simon at web.de> wrote:
>
>
>>Hello list,
>>
>>could somebody please give me short "hello world" on how to
>>use the tal-template engine ?
>>I thought it would be as easy as declaring an component with
>>the super-class "template-component" and a template-name, but
>>that seemed not to be enough.
>>I even had a look at Marco Baringers's "counter" example which uses the
>>tal-template mechanism - but didn't manage it.
>>So could you please give me some example-lines which show how
>>to implement *.tal - files ?
>>
>>Beside that (but this hasnt to do with ucw) I'm looking for a lisp-function
>>which escapes all " within a string to \" but didn't find any predifined
>>cl-function
>>so far. Any hints ?
>>
>>Thanks a lot
>> best regards
>> Marco
>>
>>
>>_______________________________________________
>>bese-devel mailing list
>>bese-devel at common-lisp.net
>>http://common-lisp.net/cgi-bin/mailman/listinfo/bese-devel
>>
>>
>>
>
>
>
>
More information about the bese-devel
mailing list