Index: openacs-4/packages/acs-templating/www/doc/noquote.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/noquote.adp,v diff -u -r1.3.2.4 -r1.3.2.5 --- openacs-4/packages/acs-templating/www/doc/noquote.adp 5 Jul 2016 12:14:22 -0000 1.3.2.4 +++ openacs-4/packages/acs-templating/www/doc/noquote.adp 7 Nov 2016 19:23:16 -0000 1.3.2.5 @@ -1,5 +1,5 @@ -{/doc/acs-templating {Templating}} {HTMLQuoting as Part of the Templating System - +{/doc/acs-templating {ACS Templating}} {HTMLQuoting as Part of the Templating System - Requirements} HTMLQuoting as Part of the Templating System - Requirements @@ -73,10 +73,13 @@ returns the quoted string. In ACS 3.x, properly written code was expected to call ns_quotehtml every time it published a string to a web page. For example:

-doc_body_append "<ul>\n" set db [ns_db gethandle] set selection
-[ns_db select $db {SELECT name FROM bboard_forums}] while {[ns_db
-getrow $db $selection]} { set_variables_after_query doc_body_append
-"<li>Forum: <tt>[ns_quotehtml $name]</tt>\n" }
+doc_body_append "<ul>\n"
+set db [ns_db gethandle]
+set selection [ns_db select $db {SELECT name FROM bboard_forums}]
+while {[ns_db getrow $db $selection]} {
+    set_variables_after_query
+    doc_body_append "<li>Forum: <tt>[ns_quotehtml $name]</tt>\n"
+}
 doc_body_append "</ul>\n"
 

Obviously, this was very error-prone, and more often than not, the programmers would forget to quote the variables that come from @@ -99,16 +102,21 @@ change is that it comes in two parts: the presentation template, and the programming logic code. The template will look like this:

-<ul> <multiple name=forums> <li>Forum:
-  <tt>\@forums.name\@</tt> </multiple> </ul>
+<ul>
+  <multiple name=forums>
+    <li>Forum: <tt>\@forums.name\@</tt>
+  </multiple>
+</ul>
 

Once you understand the (simple) workings of the multiple tag, this version strikes you as much more readable than the old one. But we're not done yet: we need to write the Tcl code that grabs forum names from the database. The db_multirow proc is designed exactly for this; it retrieves rows from the database and assigns variables from each row to template variables in each pass of a multiple of our choice.

-db_multirow forums get_forum_names { SELECT name FROM forums }
+db_multirow forums get_forum_names {
+  SELECT name FROM forums
+}
 

At this point the careful reader will wonder at which point the forum name gets quoted, and if so, how does the templating system know whether the forum name needs to be quoted or not? The answer @@ -181,9 +189,9 @@ included into the next ACS release. Since the change is incompatible, it will be announced to module owners and the general public. Explanation on how to port your existing modules and the -"gotchas" that one can expect follows in a separate document .

The discussion about speed, i.e. benchmarking results before and -after the change, is also -available .

Hrvoje Niksic

+"gotchas" that one can expect follows in a separate document .

+> +

Hrvoje Niksic