Stefan Scholl | 10 Jun 21:50

New release CL-EMB 0.4.4

New release CL-EMB 0.4.4

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:

- Multibyte external file format patch (Tomasz Skutnik)

- Speedup by memoization in expand-template-tags (Tomasz Skutnik) 

Tomasz Skutnik | 9 Jun 23:56

cl-emb speedup

Hi.

I've started some serious development using cl-emb, and found that
it's template parsing/compilation was unbearably slow. Even simple few
character template parsing and compilation results in massive CPU and
memory burn. So I've profiled it a bit using SBCL statistical profiler
and found that it was all due to very suboptimal use of
ppcre:regex-replace-all. Long story short (well, not so long)
regex-replace-all was alway passed strings, which resulted in very
costly ppcre scanner building every time any template was parsed.
Simple memoization in expand-template-tags did the trick - scanner
object is built only on first use.

Below you will find patch that modifies cl-emb accordingly. Code
heavily borrows from Edi Weitz's Hunchentoot's scanner-for-get-param
and Tim Bradshaw's memoize library. Thanks guys. Additionally patch
exports new external function clear-expand-template-tag-hash, that
clears internal cache. It's provided because template tags expansion
depends on *emb-start-marker* and *emb-end-marker* that potentially
can be modified during runtime, to there exist possibility that
someone might need to clear scanner cache after modifying start and
end marker values.

Hope that you'll find that patch useful.

Tomasz

P.S. When next cl-emb version will be released? Will my previous patch
be incorporated?
(Continue reading)

Tomasz Skutnik | 12 Apr 22:43

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

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

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

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

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.