Titanium JIRA Archive
Alloy (ALOY)

[ALOY-130] Interpret .tss files as JS, not JSON

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2012-07-26T13:24:04.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsXML
Labelsn/a
ReporterTony Lukasavage
AssigneeUnknown
Created2012-07-26T08:45:33.000+0000
Updated2018-03-07T22:25:42.000+0000

Description

This will allow styles files to lose the enclosing \{\} characters, and it will remove the need to wrap all properties in quotes. All the same compile time rules will apply though. All dynamic code still needs to go in expr() syntax. We can likely achieve the above by using eval() on the style, then using JSON.stringify() to turn it back to JSON, then continue are normal tss processing.

Comments

  1. Tony Lukasavage 2012-07-26

    For reference, the test/apps/simple/styles/index.tss before and after. No more double quotes necessary on keys, and no top-level \{\} necessary.

    before

       {
       	"Button" : {
       		"width" : expr(Ti.Platform.displayCaps.platformWidth/2),
       		"height" : Ti.UI.SIZE
       	},
       	".button" : {
       		"randomProp":"OK"
       	},
       	"#index[platform=ios]": {
       		"backgroundColor":"blue"
       	},
       	"#index[platform=ios size=tablet]": {
       		"backgroundColor":"red"
       	},
       	"#b": {
       		"randomProp" : null
       	}
       }
       

    after

       "Button" : {
       	width: expr(Ti.Platform.displayCaps.platformWidth/2),
       	height: Ti.UI.SIZE
       },
       ".button" : {
       	randomProp: 'OK'
       },
       "#index[platform=ios]": {
       	backgroundColor: 'blue'
       },
       "#index[platform=ios size=tablet]": {
       	backgroundColor: 'red'
       },
       "#b": {
       	randomProp: null
       }
       

JSON Source