Index: openacs-4/packages/acs-templating/www/doc/tagref/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/tagref/index.html,v diff -u -r1.1.1.1 -r1.1.1.1.4.1 --- openacs-4/packages/acs-templating/www/doc/tagref/index.html 13 Mar 2001 22:59:27 -0000 1.1.1.1 +++ openacs-4/packages/acs-templating/www/doc/tagref/index.html 7 Aug 2003 21:51:44 -0000 1.1.1.1.4.1 @@ -45,6 +45,7 @@
<grid>
<list>
<if>
+ <switch>
<include>
<property>
<noparse>
Index: openacs-4/packages/acs-templating/www/doc/tagref/switch.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/doc/tagref/switch.html,v
diff -u -r1.1 -r1.1.4.1
--- openacs-4/packages/acs-templating/www/doc/tagref/switch.html 14 Jan 2003 01:54:55 -0000 1.1
+++ openacs-4/packages/acs-templating/www/doc/tagref/switch.html 7 Aug 2003 21:51:44 -0000 1.1.4.1
@@ -1,84 +1,83 @@
- The switch tag is used to output one of n-sections when the switch variable matches one of the n-case statements. A default section can also be output if none of the n-case statements matches the switch variable.
+The switch tag is used to output a template section only when +a certain condition is met. You use it when you have several options to test, +thus avoiding the need for successive <if> <else> blocks.
-<switch @x@> - <case value="Fred"> - Hello Fred. +<switch flag=exact @some_var@> + <case value="a"> + A was selected </case> - <case value="Greta"> - Hello Greta. + <case value="b"> + B was selected </case> - <case value="Sam"> - Hello Sam - </case> <default> - I don't recognize your name. + Not a valid selection </default> </switch> --
Tcl-equivalent flags have the same meaning as in the tcl-switch statement. Supported flags include exact, glob, and regexp.
--<switch flag=glob @x@> - <case value="F*"> - Hello Fred. + +<switch flag=glob @some_var@> + <case value="a*"> + A value starting with "a" was selected. </case> - <case value="G*"> - Hello Greta. + <case value="b?"> + A value of "B" followed by any other character was selected. </case> - <case value="H*"> - Hello Sam + <case value="[A-Za-z]"> + A character between capital A and capital Z, lowercase a and lowercase z was selected. </case> <default> - You are in the section for people whose names start with F, G, or H. + Not a valid selection </default> </switch> --
-Case tags also have an alternative form for matching a list of items.
--
-<switch @x@> - <case in "Fred" "Greta" "Sam"> - Your must be Fred Greta or Sam, but I'm not sure which one. + +<switch flag=regexp @some_var@> + <case in "foo" "bar" "baz"> + Foo, Bar or Baz was selected </case> + <case value="a.+"> + A was selected + </case> + <case value="b.+"> + B was selected + </case> + <case value="c.+"> + C was selected + </case> <default> - I don't recognize your name. + Not a valid selection </default> </switch>-
-
Any legal variables that may be referenced in the template may -also be used in switch statements. - -
Phrases with spaces in them must be enclosed in double quotes and -curly braces to be matched correctly. Failure to quote words with spaces -correctly results in an error. -
- <case "{blue sky}"> - <td bgcolor=#0000ff> - </case>- -
<switch>
tag works the same as Tcl's switch command. exact
flag is optional, and is the default. glob
flag matches values in glob-style matching, like the Tcl
+ string match
+ command.regexp
flag enables regular expression matching,
+ (as described in the re_syntax
+ reference page).