Created
September 28, 2011 19:39
-
-
Save brianjmiller/1249009 to your computer and use it in GitHub Desktop.
Additional MakeNode _templateHandlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Y.MakeNode.prototype._templateHandlers["@@"] = function (args) { | |
args = this._parseMakeNodeArgs(args); | |
if (args.length !== 2 || args[0] === "" || args[1] === "") { | |
return; | |
} | |
var av = this.get(args[0]); | |
if (! av) { | |
return; | |
} | |
return av.get(args[1]); | |
}; | |
Y.MakeNode.prototype._templateHandlers["@p"] = function (args) { | |
args = this._parseMakeNodeArgs(args); | |
if (args.length !== 2 || args[0] === "" || args[1] === "") { | |
return; | |
} | |
var av = this.get(args[0]); | |
if (! av) { | |
return; | |
} | |
return av[args[1]]; | |
}; | |
Y.MakeNode.prototype._templateHandlers["p@"] = function (args) { | |
args = this._parseMakeNodeArgs(args); | |
if (args.length !== 2 || args[0] === "" || args[1] === "") { | |
return; | |
} | |
var pv = this[args[0]]; | |
if (! pv) { | |
return; | |
} | |
return pv.get(args[1]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't actually need to call _parsemakeNodeArgs for this one. Just splitting args on whitespace should do. The parser is useful when you want to allow for strings containing whitespace but, presumably, the arguments here would be proper identifiers and do not need to be quoted.
this allows you to call it like this: {p@ prop att} instead of {p@ "prop" "att"}, which is easier, unless you have identifiers that need quoting.