[html-template-devel] TMPL_INCLUDE and *default-template-pathname*

Chaitanya Gupta mail at chaitanyagupta.com
Wed Mar 28 10:56:28 UTC 2007


Hello,

I have noticed some strange behaviour while using TMPL_INCLUDE tags when 
*default-template-pathname* is set to some relative path. I am not sure 
whether its a bug or not, but it sure doesn't work as I expect it to -

Let's start with a some directory -

CL-USER(5): *default-pathname-defaults*
#P"/Users/chaitanya/lisp/"


Now I define a string with the TMPL_INCLUDE tag.

CL-USER(7): (setf *tmpl-string* "before test || <!-- TMPL_INCLUDE 
'temp/test-template' --> || after test")
"before test || <!-- TMPL_INCLUDE 'temp/test-template' --> || after test"


Calling fill-and-print-template works fine here.

CL-USER(8): (html-template:fill-and-print-template *tmpl-string* nil)
before test || Just a test template -  || after test


The value of *default-template-pathname* currently is

CL-USER(11): html-template:*default-template-pathname*
#P""


Now we will change it to #p"temp/"

CL-USER(12): (setf html-template:*default-template-pathname* #p"temp/")
#P"temp/"


And we also change *tmpl-string* -

CL-USER(13): (setf *tmpl-string* "before test || <!-- TMPL_INCLUDE 
'test-template' --> || after test")
"before test || <!-- TMPL_INCLUDE 'test-template' --> || after test"


Now calling fill-and-print-template doesn't work -

CL-USER(14): (html-template:fill-and-print-template *tmpl-string* nil)
Error: File #P"temp/temp/test-template" does not exist.
   [condition type: FILE-ERROR]

Restart actions (select using :continue):
  0: Return to Top Level (an "abort" restart).
  1: Abort entirely from this (lisp) process.


Upon looking at the source code, I saw that merge-pathnames was being 
called both while processing the TMPL_INCLUDE tag in 
create-template-printer-aux and while actually creating the template 
printer in create-template-printer. And indeed, tracing merge-pathnames 
reveals that this is what's happening -

CL-USER(17): (html-template:fill-and-print-template *tmpl-string* nil)
  0[2]: (MERGE-PATHNAMES "test-template" #P"temp/")
  0[2]: returned #P"temp/test-template"
  0[2]: (MERGE-PATHNAMES #P"temp/test-template" #P"temp/")
  0[2]: returned #P"temp/temp/test-template"
  0[2]: (MERGE-PATHNAMES #P"temp/temp/test-template")
  0[2]: returned #P"/Users/chaitanya/lisp/temp/temp/test-template"
  0[2]: (MERGE-PATHNAMES #P"temp/temp/test-template")
  0[2]: returned #P"/Users/chaitanya/lisp/temp/temp/test-template"
Error: File #P"temp/temp/test-template" does not exist.
   [condition type: FILE-ERROR]

Restart actions (select using :continue):
  0: Return to Top Level (an "abort" restart).
  1: Abort entirely from this (lisp) process.


This seems like a bug to me. Is this how its supposed to work? If yes, 
then how do I solve the above problem? (I don't want to set 
html-template:*default-template-pathname* to an absolute path)

Thanks,

Chaitanya




More information about the Html-template-devel mailing list