Created
December 1, 2014 15:27
-
-
Save grantges/060ff360326f1e165c6b to your computer and use it in GitHub Desktop.
Using Custom Tags to Map HTML to Ti
This file contains 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
function htmlToTi(_args){ | |
var json = {}; | |
var keys = _.keys(_args); | |
_.each(keys, function(key){ | |
switch(key){ | |
case "bgcolor": | |
case "background-color": | |
json.backgroundColor = _args[key]; | |
break; | |
case "height": | |
case "width": | |
case "top": | |
case "left": | |
case "bottom": | |
case "right": | |
json[key] = _args[key]; | |
break; | |
case "style": | |
//_.extend(json, htmlToTi() | |
break; | |
default: | |
} | |
}); | |
return json; | |
} | |
exports.creatediv = function(_args){ | |
var json = htmlToTi(_args); | |
var view = Ti.UI.createView(json); | |
return view; | |
}; | |
exports.createDIV = exports.creatediv; | |
exports.createDiv = exports.creatediv; |
This file contains 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
<Alloy> | |
<Window class="container"> | |
<div module="html" bgcolor="#f00" style="border-radius:3px" height="200" width="200"> | |
<div module="html" bgcolor="#00f" height="50" width="50" /> | |
</div> | |
</Window> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you only need
createDiv
since Alloy will camelCase it for you.