The extensibility of dojo.E is a core design principal of the framework. Not only does the framework make it easy for third party developers to extend the framework, but we take advantage of this flexibility ourselves to simplify the markup that we supply.
- Top level Tags - Are tags that are located directly under the <script> tags. dojo.E currently has two built in tags: ui and declarations.
- Namespace extensions - Developers wishing to supply there own syntax to the ui block can add a namespace handler. Examples of this would be adding a handler for the http://www.w3.org/Graphics/SVG/ namespace, which would allow SVG to be used on any browser, even IE.
- Declaration processing elements - Are objects that get created inside of the declarations tags and can be executed in a Macro or using the processRequest function. This works similar to how developers would create a dojo widget, the difference being these object's need to have only a public startup function exposed. You can look at the code for the Macro object or Xmodify object within dojo.E's _base directory.
- New widgets - This one is quite simple to do, developers just need to create an ordinary dojo widget. If the widget works through the dojoML syntax,
<div dojoType="fooco.widgets.BestWidgetEver"></div>
it will work inside of the dojo.E Markup
<fooco.widgets.BestWidgetEver/> syntax.
Sample
The following sample demonstrates how a developer would extend a top level tag.
<script type="text/javascript">
//<![CDATA[
function customTopLevelTag(){
// Testing a basic Greetings tag processor.
dojoe.registerNodeProcessor("greet", function(node){
alert(node.getAttribute("text"));
});
dojoe.processString(
"<root xmlns:foo=\"bar\"><foo:greet text=\"Hello"+
" World!\"/><greet text=\"Bye!\"/></root>"
);
}
//]]>
</script>
<script type="text/xml" dojoType="dojoe.XmlScript">
<ui>
<button onclick="customTopLevelTag()">Execute custom processor</button>
</ui>
</script>
|