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

Revision 223, 1.7 kB (checked in by scorfield, 3 years ago)

Addresses #93 by updating skeleton verbs with authors as appropriate and READMEs with known issues and caveats.

Line 
1<cfscript>
2        // Author: Nathan Strutz (strutz@gmail.com)
3        // example custom verb that compiles to a <cfcookie> 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:cookie name="" value="" expires=""/>
9        //
10        // how this works:
11        // a. validate the attributes passed in (fb_.verbInfo.attributes)
12        // b. in start mode, generate the required CFML
13        // c. in end mode, do nothing (this tag does not nest)
14        //
15        if (fb_.verbInfo.executionMode is "start") {
16                //
17                // name is required:
18                if (not structKeyExists(fb_.verbInfo.attributes,"name")) {
19                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
20                                                "Required attribute is missing",
21                                                "The attribute 'name' is required, for a 'cookie' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
22                }
23                //
24                // value is required:
25                if (not structKeyExists(fb_.verbInfo.attributes,"value")) {
26                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
27                                                "Required attribute is missing",
28                                                "The attribute 'value' is required, for a 'cookie' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
29                }
30                //
31                // expires is required:
32                if (not structKeyExists(fb_.verbInfo.attributes,"expires")) {
33                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
34                                                "Required attribute is missing",
35                                                "The attribute 'expires' is required, for a 'cookie' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
36                }
37                //
38                // start mode:
39                fb_appendLine('<cfcookie name="#fb_.verbInfo.attributes.name#" value="#fb_.verbInfo.attributes.value#" expires="#fb_.verbInfo.attributes.expires#"/>');
40        } else {
41                //
42                // end mode - do nothing
43        }
44</cfscript>
Note: See TracBrowser for help on using the browser.