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

Revision 222, 2.0 kB (checked in by scorfield, 3 years ago)

Fixes #101 by adding updated versions of Qasim's verbs.

Line 
1<cfscript>
2        // Author: Qasim Rasheed (qasimrasheed@gmail.com)
3        // example custom verb that compiles to a <cftrace> tag
4        // usage:
5        // 1. add the lexicon declaration to your circuit file:
6        //    <circuit xmlns:cf="cf/">
7        // 2. use the verb in a fuseaction:
8        //    <cf:trace text="Just testing this tag" />
9        //     
10        // For details on the use of <cftrace> tag. please refer to the documentation.
11        // http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000345.htm
12        //
13        // how this works:
14        // a. validate the attributes passed in (fb_.verbInfo.attributes) along with checking for valid value for attributes.
15        // b. in start mode, generate the required CFML
16        // c. in end mode, add the closing cftrace tag.
17        //
18       
19        if (fb_.verbInfo.executionMode is "start") {
20                fb_.abort = 'false';
21                fb_.category = '';
22                fb_.inline = 'false';
23                fb_.text = '';
24                fb_.type = 'Information';
25                fb_.var = '';
26               
27                if ( structKeyExists(fb_.verbInfo.attributes, 'category' ) )
28                        fb_.category = ' category="#fb_.verbInfo.attributes.category#"';
29               
30                if ( structKeyExists( fb_.verbInfo.attributes, 'type' ) ){
31                        fb_.type = fb_.verbInfo.attributes.type;
32                        if (not listfindnocase( 'Information,Warning,Error,Fatal Information', fb_.type ) )
33                                fb_throw(       "fusebox.badGrammar.invalidAttributeValue",
34                                "Attribute has invalid value",
35                                "The attribute 'type' must be one of the these values 'Information,Warning,Error,Fatal Information' for 'trace' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
36                }       
37               
38                if ( structKeyExists( fb_.verbInfo.attributes, 'text' ) )
39                        fb_.text = ' text="#fb_.verbInfo.attributes.text#"';
40               
41                if ( structKeyExists( fb_.verbInfo.attributes, 'var' ) )
42                        fb_.var = ' var="#fb_.verbInfo.attributes.var#"';
43                                                       
44                fb_appendLine('<cftrace abort="#fb_.abort#" inline="#fb_.inline#" type="#fb_.type#"#fb_.category##fb_.var##fb_.text#>');
45        } else {
46        // fb_.verbInfo.executionMode is "end"
47                fb_appendLine("</cftrace>");
48        }       
49</cfscript>
Note: See TracBrowser for help on using the browser.