Titanium JIRA Archive
Alloy (ALOY)

[ALOY-284] Accept Titanium SDK constants in the XML markup

GitHub Issuen/a
TypeNew Feature
Resolution Date2013-01-08T16:56:33.000+0000
Affected Version/s2012 Sprint 19
Fix Version/sAlloy 0.3.5, 2013 Sprint 02
ReporterBenjamin Hatfield


Currently, the property attributes in the view XML markup do not accept the Titanium SDK constants. For instance, the label will not appear if using:


  1. Tony Lukasavage 2012-09-20

    The core of the issue is that XML attributes are strings. They have no sense of type. So the default behavior when using the XML attributes is that the value is treated as a string. So right now, when you put the name of a Ti constant in an attribute, the generated code sees "Ti.UI.TEXT_ALIGNMENT_CENTER", not Ti.UI.TEXT_ALIGNMENT_CENTER. I will get Ti constants, Alloy.CFG values, and L() localizations working in XML attributes, but further handling of specific types will require mappings from API property names to the expected type, so conversions can be performed. One such conversion like this already exists. Check out the parser for Ti.Map.Annotation which converts the XML attribute strings for latitude and longitude to floats: https://github.com/appcelerator/alloy/blob/master/Alloy/commands/compile/parsers/Ti.Map.Annotation.js
  2. Tony Lukasavage 2012-10-01

    Moving this to after 3.0.0. Rather than do a partial fix here, we'll save it until we can actually implement a fully dynamic syntax for the xml attributes. Something along the lines of:
           <Label height="{Ti.UI.SIZE}" font="fontSize:'24dp'" onClick="{function(e){alert(e.source.id)}}"/>
  3. Tony Lukasavage 2013-01-08

    The {} syntax is being used for binding. Titanium constants will be made usable as the original description requests.

JSON Source