Tomasz Skutnik | 12 Apr 22:43
Picon

Multibyte external file format patch for cl-emb::contents-of-file function

Hi.

I've encountered the problem with contents-of-file function, that manifests itself for multibyte external file encodings (e.g. UTF-8). contents-of-file allocates (file-length in) characters, which for multibyte encodings is less then number of characters read by read-sequence. This leaves dangling characters (implementation dependent) at end of template code. Attached patch solves the problem.

Apply at will.

Thanks

Tomasz

Attachment (cl-emb-0.4.3-cof.patch): text/x-diff, 953 bytes
<div><p>Hi.<br><br>I've encountered the problem with contents-of-file function, that manifests itself for multibyte external file encodings (e.g. UTF-8). contents-of-file allocates (file-length in) characters, which for multibyte encodings is less then number of characters read by read-sequence. This leaves dangling characters (implementation dependent) at end of template code. Attached patch solves the problem.<br><br>Apply at will.<br><br>Thanks<br><br>Tomasz<br><br></p></div>
Vagif Verdi | 1 Sep 06:39
Picon

Access lexical scope.

Is it possible to access lexical scope from within a template ?

 

For example:

 

(let ((ctx ‘(:client-name “John Doe” :age 27)))

      (my-var “bla bla”)

      (run-template "int-quote.htm" ctx))

 

Is it possible to access that my-var from within a template ?

 

Regards,

Vagif

 

<div>

<div class="Section1">

<p class="MsoNormal"><span>Is it possible to access lexical scope from within a
template ?<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>For example:<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>(let ((ctx &lsquo;(:client-name &ldquo;John Doe&rdquo; :age
27)))<p></p></span></p>

<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (my-var &ldquo;bla bla&rdquo;)<p></p></span></p>

<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (run-template "int-quote.htm" ctx))<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>Is it possible to access that my-var from within a template
?<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>Regards,<p></p></span></p>

<p class="MsoNormal"><span>Vagif<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

</div>

</div>
Chris Parker | 13 Jun 01:36
Picon

What I can send to :env

Is there any way that I can send a list of objects to env?

I would love to do something like this:

<% <at> loop product-list %>
     <% (name product-list) %> <% (title product-list) %><br />
<% <at> endloop %>

where product-list is a result of a
clsql:select 'product
query where i would normally write

(loop for product in (clsql:select 'product :flatp t) do
    (print (name product))

thanks


<div><p>Is there any way that I can send a list of objects to env?<br><br>I would love to do something like this:<br><br>&lt;%  <at> loop product-list %&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;% (name product-list) %&gt; &lt;% (title product-list) %&gt;&lt;br /&gt;
<br>&lt;%  <at> endloop %&gt;<br><br>where product-list is a result of a <br>clsql:select 'product<br>query where i would normally write<br><br>(loop for product in (clsql:select 'product :flatp t) do<br>&nbsp;&nbsp;&nbsp; (print (name product))
<br><br>thanks<br><br><br></p></div>
Andrei Stebakov | 14 Apr 21:35
Picon

Integrating with Apache and Hunchentoot

I am wondering how the cl-emb can be integrated with static html pages generated by Apache or dynamic generated with Hunchentoot?
Does it work in the same way as embedded PHP? How the page with cl-emb gets generated with Apache?

Thank you,
Andrew

<div><p>I am wondering how the cl-emb can be integrated with static html pages generated by Apache or dynamic generated with Hunchentoot?<br>Does it work in the same way as embedded PHP? How the page with cl-emb gets generated with Apache?
<br><br>Thank you,<br>Andrew<br></p></div>
Daniel Gackle | 23 May 08:21
Favicon

Can't call register-emb

I’m new to Lisp, eager to learn, but having trouble getting cl-emb to work. I’m running Lispbox on Windows, CLISP 2.37 (http://www.gigamonkeys.com/lispbox/). I’ve loaded cl-emb 0.4.3 and cl-ppcre 1.2.13. When I try to evaluate the first sample expression in the cl-emb readme:

 

(cl-emb:register-emb "test1"

                     "10 stars: <% (dotimes (i 10) %>*<% ) %>")

 

… I get the following:

 

CL-PPCRE:REGEX-REPLACE-ALL: illegal keyword/value pair :SIMPLE-CALLS, T in argument list.

The allowed keywords are #1=(:START

    :END :PRESERVE-CASE)

   [Condition of type SYSTEM::SIMPLE-KEYWORD-ERROR]

 

 Backtrace:

  0: #<COMPILED-FUNCTION CL-EMB::CONSTRUCT-EMB-FUNCTION>

  1: #<COMPILED-FUNCTION #:|131 139 (DEFMETHOD REGISTER-EMB (NAME #) ...)-20-1-1|>

...

 

Can anyone help?

 

Sincerely,

Daniel

<div>

<div class="Section1">

<p class="MsoNormal"><span>I&rsquo;m new to Lisp, eager to learn, but having trouble
getting cl-emb to work. I&rsquo;m running Lispbox on Windows, CLISP 2.37 (<a href="http://www.gigamonkeys.com/lispbox/">http://www.gigamonkeys.com/lispbox/</a>).
I&rsquo;ve loaded cl-emb 0.4.3 and cl-ppcre 1.2.13. When I try to evaluate the
first sample expression in the cl-emb readme:<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>(cl-emb:register-emb
"test1"<p></p></span></p>

<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "10 stars: &lt;% (dotimes
(i 10) %&gt;*&lt;% ) %&gt;")</span><span><p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>&hellip; I get the following:<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>CL-PPCRE:REGEX-REPLACE-ALL: illegal keyword/value
pair :SIMPLE-CALLS, T in argument list.<p></p></span></p>

<p class="MsoNormal"><span>The allowed keywords are #1=(:START<p></p></span></p>

<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp; :END :PRESERVE-CASE)<p></p></span></p>

<p class="MsoNormal"><span>&nbsp;&nbsp; [Condition of type SYSTEM::SIMPLE-KEYWORD-ERROR]<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>&nbsp;</span><span>Backtrace:<p></p></span></p>

<p class="MsoNormal"><span>&nbsp; 0: #&lt;COMPILED-FUNCTION
CL-EMB::CONSTRUCT-EMB-FUNCTION&gt;<p></p></span></p>

<p class="MsoNormal"><span>&nbsp; 1: #&lt;COMPILED-FUNCTION #:|131 139 (DEFMETHOD
REGISTER-EMB (NAME #) ...)-20-1-1|&gt;<p></p></span></p>

<p class="MsoNormal"><span>...</span><span><p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>Can anyone help?<p></p></span></p>

<p class="MsoNormal"><span><p>&nbsp;</p></span></p>

<p class="MsoNormal"><span>Sincerely,<p></p></span></p>

<p class="MsoNormal"><span>Daniel <p></p></span></p>

</div>

</div>
Stefan Scholl | 19 Feb 01:08

New release CL-EMB 0.4.3

New release CL-EMB 0.4.3

CL-EMB is a library to embed Common Lisp and special template
tags into normal text files. Can be used for dynamically
generated HTML pages.

You can download it from
http://common-lisp.net/project/cl-emb/
or install with ASDF-Install.

CL-USER> (asdf:operate 'asdf:load-op :asdf-install)
CL-USER> (asdf-install:install :cl-emb)

Changes:

- Faster file reading (fast slurping from
  <http://www.emmett.ca/~sabetts/slurp.html>)

- New template tag @insert for inserting (text) files.

  Example:

    CL-USER> (emb:register-emb "test13" "The file:<pre><% @insert textfile %></pre>")
    #<CL-EMB::EMB-FUNCTION {5894326D}>
    CL-USER> (emb:execute-emb "test13" :env '(:textfile "/etc/gentoo-release"))
    "The file:<pre>Gentoo Base System version 1.6.14
    </pre>"

Admin Junk Summary | 21 Dec 10:57

Summary of junk emails blocked

Junk Box Summary
for cl-emb-devel-F1HGIaG5STRyXAeb93iumQ@public.gmane.org
 
The 1 email listed below has been placed in your personal Junk Box since your last Junk Box Summary and will be deleted after 180 days.
To receive any of these messages, click UnJunk. The message will be delivered to your inbox and the sender will be added to your Allowed list so their emails are never blocked.

Junk Box Summary
  From   Subject Reason
UnJunk 8739a-5JmTWrE4R8UWI+UwmH2aBQ@public.gmane.org   { {{{{
<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
<td width="70" height="69" valign="top"></td>
<td width="15"></td>
<td>
<span class="pt16">Junk Box Summary</span><br>for 
cl-emb-devel@...
</td>
<td>&nbsp;</td>
</tr></table>
<table width="98%" border="0" cellspacing="8" cellpadding="8"><tr><td> The 
1
email
listed below
has
been placed in your personal Junk Box since your last Junk Box Summary and will be deleted after
180
days.
<br>To receive any of these messages, click UnJunk. The message will be delivered to your inbox and the sender will be added to your Allowed list so their emails are never blocked.<br><br><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr><td bgcolor="#CAD3E1"><table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
<tr bgcolor="#DADAE6"><td height="24" colspan="5"><table width="100%" border="0" cellspacing="1" cellpadding="2"><tr>
<td>Junk Box Summary</td>
<td><div align="right">
<a href="http://mailfrontier.netmhc.com">Visit Junk Box</a> </div></td>
</tr></table></td></tr>
<tr>
<td>&nbsp;</td>
<td>From</td>
<td width="15">&nbsp;</td>
<td>Subject</td>
<td>Reason</td>
</tr>
<tr bgcolor="#F5F7FA">
<td><a href="http://mailfrontier.netmhc.com/junkbox?action=unjunk&amp;msgkey=20051221_mhcmailfrontier%2Fstore_20051221044507.mlx%3A4393&amp;useremail=cl-emb-devel%40common-lisp.net&amp;sec=198f6142bd2a77bf9ef40e2d800c3302&amp;ptr=2056555" target="_mlfunjunk">UnJunk</a></td>
<td>8739a@...</td>
<td>&nbsp;</td>
<td>{ {{{{
Stefan Scholl | 13 Aug 00:43

New release CL-EMB 0.4.2

New release CL-EMB 0.4.2

CL-EMB is a library to embed Common Lisp and special template
tags into normal text files. Can be used for dynamically
generated HTML pages.

You can download it from
http://common-lisp.net/project/cl-emb/
or install with ASDF-Install.

CL-USER> (asdf:operate 'asdf:load-op :asdf-install)
CL-USER> (asdf-install:install :cl-emb)

Changes:

- Changed internal function to escape for XML (was very slow and is
  now using code from Edi Weitz)

- optimized URL encoding

- locking mechanism for threaded/multiprocessing programs
  (*LOCKING-FUNCTION*).

  *LOCKING-FUNCTION* can be set to a locking function which must
  accept a function as parameter. The locking function gets
  called whenever CL-EMB accesses a global hash table.
  IMPORTANT: The locking function must return the value of
  the function it calls!

  Example:
        (defvar *emb-lock* (kmrcl::make-lock "emb-lock")
          "Lock for CL-EMB.")

        (defun emb-lock-function (func)
          "Lock function for CL-EMB."
          (kmrcl::with-lock-held (*emb-lock*)
            (funcall func)))

        (setf emb:*locking-function* 'emb-lock-function)

Stefan Scholl | 7 Aug 19:38

New release CL-EMB 0.4.1

New release CL-EMB 0.4.1

CL-EMB is a library to embed Common Lisp and special template
tags into normal text files. Can be used for dynamically
generated HTML pages.

You can download it from
http://common-lisp.net/project/cl-emb/
or install with ASDF-Install.

CL-USER> (asdf:operate 'asdf:load-op :asdf-install)
CL-USER> (asdf-install:install :cl-emb)

Changes:

- Removed some compiler notes when registering emb functions.

- @include now uses supplied path relative to current template.

Stefan Scholl | 20 Jun 15:52

New release CL-EMB 0.4.0 (API CHANGES!)

New release CL-EMB 0.4.0

CL-EMB is a library to embed Common Lisp and special template
tags into normal text files. Can be used for dynamically
generated HTML pages.

You can download it from
http://common-lisp.net/project/cl-emb/
or install with ASDF-Install.

CL-USER> (asdf:operate 'asdf:load-op :asdf-install)
CL-USER> (asdf-install:install :cl-emb)

Changes:
- Extended way to access environment (the supplied plist)
  with template tags.

  E.g.:  <% @var foo/bar %> 
         --> Like accessing (GETF (GETF ENV :FOO) :BAR)

  When your're inside a nested loop you can access the
  elements of the toplevel by starting the parameter with
  a slash.

CL-USER> (emb:register-emb "test11" "<% @loop bands %>Band: <% @var band %> (Genre: <% @var /genre
%>)<br><% @endloop %>")
#<CL-EMB::EMB-FUNCTION {58ADB12D}>
CL-USER> (emb:execute-emb "test11" :env '(:genre "Rock" :bands ((:band "Queen") (:band "The Rolling
Stones") (:band "ZZ Top"))))
"Band: Queen (Genre: Rock)<br>Band: The Rolling Stones (Genre: Rock)<br>Band: ZZ Top (Genre: Rock)<br>"

CL-USER> (emb:register-emb "test12" "<% @repeat /foo/bar/count %>*<% @endrepeat %>")
#<CL-EMB::EMB-FUNCTION {58B7583D}>
CL-USER> (emb:execute-emb "test12" :env '(:foo (:bar (:count 42))))
"******************************************"

_______________________________________________
cl-emb-devel site list
cl-emb-devel@...
http://common-lisp.net/mailman/listinfo/cl-emb-devel

Stefan Scholl | 15 Jun 10:51

New release CL-EMB 0.3.2

New release CL-EMB 0.3.2

CL-EMB is a library to embed Common Lisp and special template
tags into normal text files. Can be used for dynamically
generated HTML pages.

You can download it from
http://common-lisp.net/project/cl-emb/
or install with ASDF-Install.

CL-USER> (asdf:operate 'asdf:load-op :asdf-install)
CL-USER> (asdf-install:install :cl-emb)

Changes:
- Bugfix regarding the template tags @include and @call
  The generated code wasn't correct after the API changes
  in 0.3.0