[html-template-devel] Possibility of changing tag names

Luis Oliveira luismbo at netcabo.pt
Thu Sep 16 22:39:19 UTC 2004


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 @@
     <li><a href="#delete-from-template-cache"><code>delete-from-template-cache</code></a>
     <li><a href="#template-start-marker"><code>*template-start-marker*</code></a>
     <li><a href="#template-end-marker"><code>*template-end-marker*</code></a>
+    <li><a href="#template-var-token"><code>*template-var-token*</code></a>
+    <li><a href="#template-if-start-token"><code>*template-if-start-token*</code></a>
+    <li><a href="#template-else-token"><code>*template-else-token*</code></a>
+    <li><a href="#template-if-end-token"><code>*template-if-end-token*</code></a>
+    <li><a href="#template-loop-start-token"><code>*template-loop-start-token*</code></a>
+    <li><a href="#template-loop-end-token"><code>*template-loop-end-token*</code></a>
+    <li><a href="#template-include-token"><code>*template-include-token*</code></a>
     <li><a href="#default-template-pathname"><code>*default-template-pathname*</code></a>
     <li><a href="#default-template-output"><code>*default-template-output*</code></a>
     <li><a href="#convert-nil-to-empty-string"><code>*convert-nil-to-empty-string*</code></a>
@@ -721,6 +728,55 @@
 </blockquote>
 
 <p><br>[Special variable]
+<br><a class=none name="template-var-token"><b>*template-var-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>TMPL_VAR</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">VAR tag</a>. 
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-if-start-token"><b>*template-if-start-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>TMPL_IF</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">IF tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-else-token"><b>*template-else-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>TMPL_ELSE</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">ELSE tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-if-end-token"><b>*template-if-end-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>/TMPL_IF</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">closing IF tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-loop-start-token"><b>*template-loop-start-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>LOOP</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">LOOP tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-loop-end-token"><b>*template-loop-end-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>/LOOP</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">closing LOOP tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
+<br><a class=none name="template-include-token"><b>*template-include-token*</b></a>
+
+<blockquote><br>
+This should be a string (the default is <code>INCLUDE</code>) which is used at <a href="#semantics">generation time</a> to determine the occurrence of a <a href="#syntax">INCLUDE tag</a>.
+</blockquote>
+
+<p><br>[Special variable]
 <br><a class=none name="default-template-pathname"><b>*default-template-pathname*</b></a>
 
 <blockquote><br>
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


More information about the Html-template-devel mailing list