From penguin at ocean.vvo.ru Thu Mar 1 12:15:31 2007 From: penguin at ocean.vvo.ru (Igor Plekhov) Date: Thu, 1 Mar 2007 22:15:31 +1000 Subject: [html-template-devel] external format in an included template printer Message-ID: <20070301121531.GI10633@ocean.vvo.ru> Function #'create-template-printer has :external-format key parameter which is used when opening a file with a template to be filled. But if that file s some other file, than :external-format supplied is not used when opening the second file as it should be. In #'create-template-printer-aux function #'create-template-printer function is called with an included file only. May be it is worth to make a special variable like *hunchentoot-default-external-format* for default value of :external-format parameter for #'create-template-printer function. In SBCL special variable sb-impl::*default-external-format* can be binded to an external-format required as a workaround. -- Registered Linux User #124759 From edi at agharta.de Fri Mar 9 13:12:01 2007 From: edi at agharta.de (Edi Weitz) Date: Fri, 09 Mar 2007 14:12:01 +0100 Subject: [html-template-devel] New release 0.9.0 (Was: external format in an included template printer) In-Reply-To: <20070301121531.GI10633@ocean.vvo.ru> (Igor Plekhov's message of "Thu, 1 Mar 2007 22:15:31 +1000") References: <20070301121531.GI10633@ocean.vvo.ru> Message-ID: On Thu, 1 Mar 2007 22:15:31 +1000, Igor Plekhov wrote: > Function #'create-template-printer has :external-format key > parameter which is used when opening a file with a template to be > filled. > > But if that file s some other file, than > :external-format supplied is not used when opening the second file > as it should be. Yes, it makes sense to change that. I've done that in the new version. Thanks, Edi. From mail at chaitanyagupta.com Wed Mar 28 10:56:28 2007 From: mail at chaitanyagupta.com (Chaitanya Gupta) Date: Wed, 28 Mar 2007 16:26:28 +0530 Subject: [html-template-devel] TMPL_INCLUDE and *default-template-pathname* Message-ID: 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 || || after test") "before test || || 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 || || after test") "before test || || 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 From edi at agharta.de Wed Mar 28 14:34:33 2007 From: edi at agharta.de (Edi Weitz) Date: Wed, 28 Mar 2007 16:34:33 +0200 Subject: [html-template-devel] TMPL_INCLUDE and *default-template-pathname* In-Reply-To: (Chaitanya Gupta's message of "Wed, 28 Mar 2007 16:26:28 +0530") References: Message-ID: On Wed, 28 Mar 2007 16:26:28 +0530, Chaitanya Gupta wrote: > 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) I'm not sure I'd call this a bug - I definitely wouldn't expect the default pathname to be a relative one. What are you trying to achieve by this? Cheers, Edi. From mail at chaitanyagupta.com Thu Mar 29 12:52:07 2007 From: mail at chaitanyagupta.com (Chaitanya Gupta) Date: Thu, 29 Mar 2007 18:22:07 +0530 Subject: [html-template-devel] Re: TMPL_INCLUDE and *default-template-pathname* In-Reply-To: References: Message-ID: Edi Weitz wrote: > On Wed, 28 Mar 2007 16:26:28 +0530, Chaitanya Gupta wrote: > >> 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) > > I'm not sure I'd call this a bug - I definitely wouldn't expect the > default pathname to be a relative one. What are you trying to achieve > by this? The reason I was setting default pathname to a relative one was because I want the app to be free of any absolute paths i.e I should be able to move the whole thing from one directory to another without any changes whatsoever. In any case, I realized the solution is simple enough. Evaluating this form on startup - (setf html-template:*default-template-pathname* (merge-pathnames #p"templates/" *default-pathname-defaults*)) Sets default template pathname to an absolute one and also keeps our app pathname agnostic. Thanks, Chaitanya