From lam at tuxfamily.org Thu Sep 9 16:06:37 2004 From: lam at tuxfamily.org (Nicolas Lamirault) Date: Thu, 09 Sep 2004 18:06:37 +0200 Subject: [html-template-devel] question about *default-template-pathname* Message-ID: <87llfjmnoy.fsf@tuxfamily.org> i use html-template in 2 projects i have a macro like this : (defmacro print-template ((page) &body body) `(ml:output-html-page (with-output-to-string (stream) (let ((*default-template-output* stream) (tp (create-template-printer ,page)) ... (fill-and-print-template tp (list :title tile :author author , at body))))))) and i have a start function which have an argument to set default-template-pathname*, like this : (start-project "/location/of/templates/" file-config) and in start-project : (setf html-template:*default-template-pathname* template-dir) but i have a problem when my 2 projects are loading because each one modify *default-template-pathname* is there a possibility to have a default template directory for each project ? thanks for any help -- Nicolas Lamirault From edi at agharta.de Fri Sep 10 11:31:47 2004 From: edi at agharta.de (Edi Weitz) Date: Fri, 10 Sep 2004 13:31:47 +0200 Subject: [html-template-devel] question about *default-template-pathname* In-Reply-To: <87llfjmnoy.fsf@tuxfamily.org> (Nicolas Lamirault's message of "Thu, 09 Sep 2004 18:06:37 +0200") References: <87llfjmnoy.fsf@tuxfamily.org> Message-ID: <87llfibbrw.fsf@bird.agharta.de> On Thu, 09 Sep 2004 18:06:37 +0200, Nicolas Lamirault wrote: > i use html-template in 2 projects > i have a macro like this : > > (defmacro print-template ((page) &body body) > `(ml:output-html-page > (with-output-to-string (stream) > (let ((*default-template-output* stream) > (tp (create-template-printer ,page)) > ... > (fill-and-print-template tp > (list :title tile > :author author > , at body))))))) > > and i have a start function which have an argument to set > default-template-pathname*, like this : > > (start-project "/location/of/templates/" file-config) > > and in start-project : > > (setf html-template:*default-template-pathname* template-dir) > > but i have a problem when my 2 projects are loading > because each one modify *default-template-pathname* > > is there a possibility to have a default template directory > for each project ? Well, it's a special variable. Why don't you rebind it with LET instead of changing its value with SETF? That should do the trick. Cheers, Edi. From luismbo at netcabo.pt Thu Sep 16 22:39:19 2004 From: luismbo at netcabo.pt (Luis Oliveira) Date: Thu, 16 Sep 2004 23:39:19 +0100 Subject: [html-template-devel] Possibility of changing tag names Message-ID: <20040916223919.GB1033@nhop> Hi, First off, many thanks for you great Lisp softwares. They are useful for both using and reading. :-) After seeing the *template-(start|end)-marker* special variables I wondered why not do that same for the TMPL_* tokens. I'm not sure if it's a good idea or not but since it was so trivial to implement I'm sending you a patch in attach. The documention might need further editing. Thanks, -- Lu?s Oliveira Veras tio, kion mi trifoje http://student.dei.uc.pt/~lmoliv/ diras al vi. Equipa Portuguesa do Translation Project http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt -------------- next part -------------- diff -ru html-template-0.1.2/doc/index.html html-template-new/doc/index.html --- html-template-0.1.2/doc/index.html 2004-09-16 21:51:40.000000000 +0100 +++ html-template-new/doc/index.html 2004-09-16 23:29:22.000000000 +0100 @@ -85,6 +85,13 @@
  • delete-from-template-cache
  • *template-start-marker*
  • *template-end-marker* +
  • *template-var-token* +
  • *template-if-start-token* +
  • *template-else-token* +
  • *template-if-end-token* +
  • *template-loop-start-token* +
  • *template-loop-end-token* +
  • *template-include-token*
  • *default-template-pathname*
  • *default-template-output*
  • *convert-nil-to-empty-string* @@ -721,6 +728,55 @@


    [Special variable] +
    *template-var-token* + +


    +This should be a string (the default is TMPL_VAR) which is used at generation time to determine the occurrence of a VAR tag. +
    + +


    [Special variable] +
    *template-if-start-token* + +


    +This should be a string (the default is TMPL_IF) which is used at generation time to determine the occurrence of a IF tag. +
    + +


    [Special variable] +
    *template-else-token* + +


    +This should be a string (the default is TMPL_ELSE) which is used at generation time to determine the occurrence of a ELSE tag. +
    + +


    [Special variable] +
    *template-if-end-token* + +


    +This should be a string (the default is /TMPL_IF) which is used at generation time to determine the occurrence of a closing IF tag. +
    + +


    [Special variable] +
    *template-loop-start-token* + +


    +This should be a string (the default is LOOP) which is used at generation time to determine the occurrence of a LOOP tag. +
    + +


    [Special variable] +
    *template-loop-end-token* + +


    +This should be a string (the default is /LOOP) which is used at generation time to determine the occurrence of a closing LOOP tag. +
    + +


    [Special variable] +
    *template-include-token* + +


    +This should be a string (the default is INCLUDE) which is used at generation time to determine the occurrence of a INCLUDE tag. +
    + +


    [Special variable]
    *default-template-pathname*


    diff -ru html-template-0.1.2/packages.lisp html-template-new/packages.lisp --- html-template-0.1.2/packages.lisp 2004-09-16 21:48:35.000000000 +0100 +++ html-template-new/packages.lisp 2004-09-16 23:24:51.000000000 +0100 @@ -39,6 +39,13 @@ #:clear-template-cache #:*template-start-marker* #:*template-end-marker* + #:*template-var-token* + #:*template-if-start-token* + #:*template-else-token* + #:*template-if-end-token* + #:*template-loop-start-token* + #:*template-loop-end-token* + #:*template-include-token* #:*default-template-pathname* #:*default-template-output* #:*convert-nil-to-empty-string* @@ -69,6 +76,13 @@ "CLEAR-TEMPLATE-CACHE" "*TEMPLATE-START-MARKER*" "*TEMPLATE-END-MARKER*" + "*TEMPLATE-VAR-TOKEN*" + "*TEMPLATE-IF-START-TOKEN*" + "*TEMPLATE-ELSE-TOKEN*" + "*TEMPLATE-IF-END-TOKEN*" + "*TEMPLATE-LOOP-START-TOKEN*" + "*TEMPLATE-LOOP-END-TOKEN*" + "*TEMPLATE-INCLUDE-TOKEN*" "*DEFAULT-TEMPLATE-PATHNAME*" "*DEFAULT-TEMPLATE-OUTPUT*" "*CONVERT-NIL-TO-EMPTY-STRING*" diff -ru html-template-0.1.2/specials.lisp html-template-new/specials.lisp --- html-template-0.1.2/specials.lisp 2004-09-16 21:48:43.000000000 +0100 +++ html-template-new/specials.lisp 2004-09-16 23:25:45.000000000 +0100 @@ -37,6 +37,27 @@ (defvar *template-end-marker* "-->" "The string template tags must end with") +(defvar *template-var-token* "TMPL_VAR" + "The string for the VAR tag") + +(defvar *template-if-start-token* "TMPL_IF" + "The string for the IF tag") + +(defvar *template-else-token* "TMPL_ELSE" + "The string for the ELSE tag") + +(defvar *template-if-end-token* "/TMPL_IF" + "The string for the closing IF tag") + +(defvar *template-loop-start-token* "TMPL_LOOP" + "The string for the LOOP tag") + +(defvar *template-loop-end-token* "/TMPL_LOOP" + "The string for the closing LOOP tag") + +(defvar *template-include-token* "TMPL_INCLUDE" + "The string for the INCLUDE tag") + (defvar *printer-hash* (make-hash-table :test #'equal) "The cache for template printers. Each entry is of the form (PRINTER . WRITE-DATE).") diff -ru html-template-0.1.2/template.lisp html-template-new/template.lisp --- html-template-0.1.2/template.lisp 2004-09-16 21:48:52.000000000 +0100 +++ html-template-new/template.lisp 2004-09-16 23:27:22.000000000 +0100 @@ -179,7 +179,7 @@ (signal-template-syntax-error "EOF while inside of tag starting with ~S" *template-start-marker*)))))) - (cond ((string-equal token "TMPL_INCLUDE") + (cond ((string-equal token *template-include-token*) ;; TMPL_INCLUDE tag - first read the pathname which has to ;; follow and merge it with *DEFAULT-TEMPLATE-PATHNAME* (let* ((pathname (read-tag-rest :read-attribute t :intern nil)) @@ -209,7 +209,7 @@ merged-pathname next-fn) else-follows)))) - ((string-equal token "TMPL_VAR") + ((string-equal token *template-var-token*) ;; TMPL_VAR tag - first read the symbol which has to ;; follow and intern it (let ((symbol (read-tag-rest :read-attribute t))) @@ -226,7 +226,7 @@ symbol next-fn) else-follows)))) - ((string-equal token "TMPL_LOOP") + ((string-equal token *template-loop-start-token*) ;; TMPL_LOOP tag - first read the symbol which has to ;; follow and intern it (let* ((symbol (read-tag-rest :read-attribute t)) @@ -255,7 +255,7 @@ loop-fn next-fn) else-follows)))) - ((string-equal token "/TMPL_LOOP") + ((string-equal token *template-loop-end-token*) (unless (eq end-token :loop) ;; check if we expected /TMPL_LOOP here, i.e. if an open ;; TMPL_LOOP was pending @@ -268,7 +268,7 @@ ;; this is the end of some TMPL_LOOP body (create-simple-printer (cons (skip-leading-whitespace string) string-stack))) - ((string-equal token "TMPL_IF") + ((string-equal token *template-if-start-token*) ;; TMPL_IF tag - first read the symbol which has to follow ;; and intern it (let ((symbol (read-tag-rest :read-attribute t))) @@ -315,7 +315,7 @@ else-fn next-fn) else-follows)))))) - ((string-equal token "TMPL_ELSE") + ((string-equal token *template-else-token*) (unless (eq end-token :else) ;; check if we expected /TMPL_ELSE here, i.e. if an open ;; TMPL_IF was pending and we haven't seen TMPL_ELSE @@ -333,7 +333,7 @@ ;; return a true second value to denote that we've seen ;; TMPL_ELSE t)) - ((string-equal token "/TMPL_IF") + ((string-equal token *template-if-end-token*) (unless (or (eq end-token :if) (eq end-token :else)) ;; check if we expected /TMPL_IF here, i.e. if an open ;; TMPL_IF was pending From edi at agharta.de Sun Sep 19 22:34:55 2004 From: edi at agharta.de (Edi Weitz) Date: Mon, 20 Sep 2004 00:34:55 +0200 Subject: [html-template-devel] Possibility of changing tag names In-Reply-To: <20040916223919.GB1033@nhop> (Luis Oliveira's message of "Thu, 16 Sep 2004 23:39:19 +0100") References: <20040916223919.GB1033@nhop> Message-ID: <87hdptsx9s.fsf@miles.agharta.de> Hi! On Thu, 16 Sep 2004 23:39:19 +0100, Luis Oliveira wrote: > First off, many thanks for you great Lisp softwares. They are useful > for both using and reading. :-) Thanks... :) > After seeing the *template-(start|end)-marker* special variables I > wondered why not do that same for the TMPL_* tokens. I'm not sure if > it's a good idea or not but since it was so trivial to implement I'm > sending you a patch in attach. > > The documention might need further editing. I already applied the patch and almost released a new version but I didn't because the documentation for this really needs to be improved. No kidding - I like it when software is well-documented and I currently can't come up with a good terminology to explain what these new special variables do with respect to the rest of the documentation. You know what I mean? "Determine the occurence of a VAR tag." What is a "VAR tag?" It hasn't been defined elsewhere, not even mentioned. Furthermore, the section about semantics uses the default values, like TMPL_VAR, to explain how HTML-TEMPLATE works. So these parts of the docs should also be changed to accomodate your patch but on the other hand they shouldn't be too abstract so people still understand what's happening. I'm a bit in a hurry so I don't have the time to sit down and think about this. So either you send an improved version of the docs or this'll have to wait until I have more time. Thanks, Edi.