root / framework / trunk / extensions / lexicon / cf / switch.cfm

Revision 225, 1.3 kB (checked in by scorfield, 2 years ago)

Fixes #134 by correcting the typo in the comment.

Line 
1<cfscript>
2        // example custom verb that compiles to a <cfswitch> tag
3        // usage:
4        // 1. add the lexicon declaration to your circuit file:
5        //    <circuit xmlns:cf="cf/">
6        // 2. use the verb in a fuseaction:
7        //    <cf:switch expression="#someExpr#">
8        //    <cf:case value="someValue">
9        //        ... some code ...
10        //    </cf:case>
11        //    <cf:case value="anotherValue|andAnother" delimiters="|">
12        //        ... more code ...
13        //    </cf:case>
14        //    <cf:defaultcase>
15        //        ... default code ...
16        //    </cf:defaultcase>
17        //    </cf:switch>
18        //
19        // how this works:
20        // a. validate the attributes passed in (fb_.verbInfo.attributes)
21        // b. in start mode, generate the required CFML
22        // c. in end mode, generate the required CFML
23        //
24        if (fb_.verbInfo.executionMode is "start") {
25                //
26                // validate attributes:
27                // expression is required:
28                if (not structKeyExists(fb_.verbInfo.attributes,"expression")) {
29                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
30                                                "Required attribute is missing",
31                                                "The attribute 'expression' is required, for a 'switch' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
32                }
33                //
34                // start mode:
35                fb_appendLine('<' & 'cfswitch expression="#fb_.verbInfo.attributes.expression#">');
36        } else {
37                //
38                // end mode:
39                fb_appendLine('<' & '/cfswitch>');
40        }
41</cfscript>
Note: See TracBrowser for help on using the browser.