You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by le...@google.com on 2008/09/22 21:53:45 UTC
Allow out of order tag declaration in OST
Reviewers: shindig-dev,
Description:
This change will cause all the tags with a ":" in them to get handled as
potential custom tags, removing the requirement that custom tags be
registered prior to template compilation.
If at run time no custom tag is found for a particular tag, a warning is
shown and template rendering is able to proceed.
JIRA issue: https://issues.apache.org/jira/browse/SHINDIG-620
Please review this at http://codereview.appspot.com/5694
Affected files:
features/opensocial-templates/base.js
features/opensocial-templates/compiler.js
features/opensocial-templates/namespaces.js
Index: features/opensocial-templates/base.js
===================================================================
--- features/opensocial-templates/base.js (revision 697963)
+++ features/opensocial-templates/base.js (working copy)
@@ -220,7 +220,8 @@
os.doTag = function(node, ns, tag, data, context) {
var tagFunction = os.getCustomTag(ns, tag);
if (!tagFunction) {
- throw "Custom tag <" + ns + ":" + tag + "> not defined.";
+ os.warn("Custom tag <" + ns + ":" + tag + "> not defined.");
+ return;
}
// Process tag's inner content before processing the tag.
Index: features/opensocial-templates/compiler.js
===================================================================
--- features/opensocial-templates/compiler.js (revision 697963)
+++ features/opensocial-templates/compiler.js (working copy)
@@ -429,20 +429,19 @@
output = document.createElement("span");
output.setAttribute(os.ATT_customtag, node.tagName);
- var custom;
- if (custom = os.checkCustom_(node.tagName)) {
- os.appendJSTAttribute_(output, ATT_eval, "os.doTag(this, \""
- + custom[0] + "\", \"" + custom[1] + "\", $this, $context)");
- var context = node.getAttribute("context") || "$this||true";
- output.setAttribute(ATT_select, context);
+ var custom = node.tagName.split(":");
+ os.appendJSTAttribute_(output, ATT_eval, "os.doTag(this, \""
+ + custom[0] + "\", \"" + custom[1] + "\", $this, $context)");
+ var context = node.getAttribute("context") || "$this||true";
+ output.setAttribute(ATT_select, context);
- // For os:Render, create a parent node reference.
- if (node.tagName == "os:render" || node.tagName == "os:Render" ||
- node.tagName == "os:renderAll" || node.tagName
== "os:RenderAll") {
- os.appendJSTAttribute_(output, ATT_values, os.VAR_parentnode
+ ":" +
- os.VAR_node);
- }
+ // For os:Render, create a parent node reference.
+ if (node.tagName == "os:render" || node.tagName == "os:Render" ||
+ node.tagName == "os:renderAll" || node.tagName
== "os:RenderAll") {
+ os.appendJSTAttribute_(output, ATT_values, os.VAR_parentnode + ":"
+
+ os.VAR_node);
}
+
os.copyAttributes_(node, output, node.tagName);
} else {
output = os.xmlToHtml_(node);
Index: features/opensocial-templates/namespaces.js
===================================================================
--- features/opensocial-templates/namespaces.js (revision 697963)
+++ features/opensocial-templates/namespaces.js (working copy)
@@ -119,25 +119,6 @@
};
/**
- * Checks if an XML tag corresponds to a known custom function.
- * If so, the namespace and tag name are returned in an array.
- * @param {string} nodeName Name of XML tag.
- * @return {Array.<string>|null}
- */
-os.checkCustom_ = function(nodeName) {
- var index;
- if ((index = nodeName.indexOf(':')) < 0) {
- return null;
- }
- var ns = nodeName.substring(0, index);
- var tag = nodeName.substring(index + 1);
- if (os.getCustomTag(ns, tag)) {
- return [ns, tag];
- }
- return null;
-};
-
-/**
* Define 'os:renderAll' and 'os:Html' tags and the @onAttach attribute
*/
os.defineBuiltinTags = function() {