Lexicons in fusebox 5
If you read the fusebox 5 documentation about 'Extending the framework' you will read:
Fusebox 4.1 introduced the concept of custom lexicons as an "experimental" feature that was intended to allow developers to extend the XML grammar of the core Fusebox framework.
So now it appears that fusebox 5 supports lexicons as a defined feature.
Fusebox 5 supports per-circuit custom lexicons using XML namespace syntax. You declare a custom lexicon using the xmlns attribute in the
tag: <circuit xmlns:prefix="path/to/verbs/">
...
</circuit>As with Fusebox 4.1, the path is relative to the lexicon/ directory in your application root.
You invoke custom verbs using XML namespace syntax as follows:
<prefix:verb />
Hang on... verbs ??? Barney Boisvert wrote a great summary:
A verb is an XML tag you use in circuit.xml, a lexicon is a collection of verbs. Or, a verb is a CFM file that implements an XML tag, and a lexicon is a directory of such files. Lexicons are declared via an XML namespace in the root of your circuit.xml file, and then you can use verbs from the lexicon anywhere in the circuit.
<circuit xmlns:cf="/path/to/cf/lexicon">
...
<cf:yourLexiconName ...>
...
</cf:yourLexiconName>
...
</circuit>That declares the prefix "cf" as a reference to the lexicon whose implementation is stored at /path/to/cf/lexicon. The "cf:yourLexiconName" tag means find the file yourLexiconName.cfm in that directory, and execute it as a verb implementation, supplying it the appropriate attributes and context.
So why would I want to use a lexicon?
Use this example. You are Mr Fusebox creating web applications but your intranet developer is Ms Model-Glue. One day Mr HR says I need the web app to interact with employee directory so people can access it externally. How can you get your FB and MG systems to interact... yep you've guess it: lexicons. Take a look at Sean Corfields example of doing this. To quote Sean on his example:
It essentially implements something like Model-Glue but in Fusebox, as custom XML grammar
Essentially your custom lexicon allows your to develop the framework behaviors without having to hack the core files.
So lets looks at the dump verb (cf lexicon). With the FB5 skeleton application you get a directory called lexicons with a sub directory called CF where you put your CF style verbs (for good practice if you have lexicons related to Ajax (for example) create a directory called Ajax and put your verbs in there).
Similar to custom tags you have a start and end execution mode (fb_.verbInfo.executionMode)
which can be checked for like:
if (fb_.verbInfo.executionMode is "start") {
... // start mode } else {
...// end mode }
</cfscript>
You then have you attributes scope accessable via fb_.verbInfo (fb_.verbInfo.attributes):
fb_.label = 'label="#fb_.verbInfo.attributes.label#"';
} else {
fb_.label = '';
}
So all you have to do it apply your normal CF logic that you wish to happen within these tags and away you go.
Something to note is with fb_.verbInfo you have access to variables 'circuit' and 'fuseaction' - which is helpful in debugging. So altogether it looks like:
// example custom verb that compiles to a <cfdump> tag // usage: // 1. add the lexicon declaration to your circuit file: // <circuit xmlns:cf="cf/"> // 2. use the verb in a fuseaction: // <cf:dump var="#somevariable#" /> // <cf:dump label="some label" var="#somevariable#" /> //
// how this works: // a. validate the attributes passed in (fb_.verbInfo.attributes) // b. in start mode, generate the required CFML // c. in end mode, do nothing (this tag does not nest) //
if (fb_.verbInfo.executionMode is "start") {
//
// validate attributes: // var is required: if (not structKeyExists(fb_.verbInfo.attributes,"var")) {
fb_throw("fusebox.badGrammar.requiredAttributeMissing",
"Required attribute is missing",
"The attribute 'var' is required, for a 'dump' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
// label is optional, create the text to generate - note the quoting technique: if (structKeyExists(fb_.verbInfo.attributes,"label")) {
fb_.label = 'label="#fb_.verbInfo.attributes.label#"';
} else {
fb_.label = '';
}
//
// start mode: fb_appendLine('<cfdump #fb_.label# var="#fb_.verbInfo.attributes.var#">');
} else {
//
// end mode - do nothing }
</cfscript>
Take a look at a good thread that Daniel Schmid started on the fusebox 5 mailing list asking how to translate a custom tag into a lexicon.
Another thing to remember is that lexicons write to the parsed file at compile time, not at runtime.





I'm looking at Canvas Wiki (MG) but want the FB love and warmth I've grown to cherish. So I'm looking at porting (looking, considering). :-)
The first stage is doiong a little research on the porting process and how easy?
<a href="http://louisvuittonlv.blog.hexun.com/">designer clothes </a>
<a href="http://www.ecmaimai.com">ecmaimai</a>
<a href="http://i.mop.com/lvlala"> designer handbags </a>
<a href="http://handbagsmastercom.blogspot.com/"> latest fashion </a>
<a href="http://www.handbagsmaster.com">handbags master</a>
<a href="http://blog.jiaoshi.com.cn/blog.php?uid=2927"... fashion clothes </a>
<a href="http://blog.sdgb.cn/lily1986/">style </a>
<a href="http://blog.uuuso.com/louisvuitton"> fashion style </a>
<a href="http://www.watchesestore.com">replica rolex</a>
<a href="http://www.replicaestore.com"> replica handbags</a>replicaestore.com
<a href="http://www.watchesestore.com">replica rolex</a>
<a href="http://www.replicaestore.com"> replica handbags</a>replicaestore.com