Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1661] AttributedString causes error when used inside ListView template

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2015-10-28T01:04:43.000+0000
Affected Version/sAppcelerator Studio 4.3.1
Fix Version/sn/a
ComponentsAlloy
Labelsn/a
ReporterChristi
AssigneeShak Hossain
Created2015-10-02T18:59:59.000+0000
Updated2016-03-08T07:38:09.000+0000

Description

Attempting to use attributed strings within a label on a ListView template causes compiler errors. Normally, an attributed string can exist within a label like so: {{ }} Here is the code I wrote as an example of this issue: {{ }} This code causes the following compiler errors: [INFO] : [index.xml] view processing... [INFO] : style: "index.tss" [INFO] : view: "index.xml" [DEBUG] : /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.Label.js:20 [DEBUG] : attributedStringsymbol = state.parent.symbol; [DEBUG] : ^ [ERROR] : : Cannot read property 'symbol' of undefined [DEBUG] : at Object.CU.generateNodeExtended.post (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.Label.js:20:43) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/base.js:14:17) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/default.js:10:27) [DEBUG] : at parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.AttributedString.js:32:39) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.AttributedString.js:10:27) [DEBUG] : at Object.exports.generateNode (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:317:48) [DEBUG] : at Object.exports.generateNodeExtended (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:254:17) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.Label.js:17:15 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.Label.js:15:4) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.Label.js:7:27) [DEBUG] : at Object.exports.generateNode (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:317:48) [DEBUG] : at Object.exports.generateNodeExtended (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:254:17) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:64:15 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:54:5) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Alloy.Abstract.ItemTemplate.js:10:27) [DEBUG] : at Object.exports.generateNode (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:317:48) [DEBUG] : at Object.exports.generateNodeExtended (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:254:17) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:131:17 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:122:6 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:48:4) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/base.js:11:17) [DEBUG] : at Object.exports.parse (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/parsers/Ti.UI.ListView.js:29:27) [DEBUG] : at Object.exports.generateNode (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:317:48) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:401:29 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at Object.exports.generateNode (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/compilerUtils.js:392:5) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/index.js:676:28 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at parseAlloyComponent (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/index.js:665:5) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/index.js:289:6 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at /Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/index.js:278:6 [DEBUG] : at Array.forEach (native) [DEBUG] : at Function._.each._.forEach (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/lib/alloy/underscore.js:79:11) [DEBUG] : at module.exports (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/commands/compile/index.js:274:4) [DEBUG] : at Object. (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/Alloy/alloy.js:113:46) [DEBUG] : at Module._compile (module.js:456:26) [DEBUG] : at Object.Module._extensions..js (module.js:474:10) [DEBUG] : at Module.load (module.js:356:32) [DEBUG] : at Function.Module._load (module.js:312:12) [DEBUG] : at Module.require (module.js:364:17) [DEBUG] : at require (module.js:380:17) [DEBUG] : at Object. (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/node_modules/alloy/bin/ [DEBUG] : alloy:3:1) [DEBUG] : at Module._compile (module.js:456:26) [DEBUG] : at Object.Module._extensions..js (module.js:474:10) [DEBUG] : at Module.load (module.js:356:32) [DEBUG] : at Function.Module._load (module.js:312:12) [DEBUG] : at Function.Module.runMain (module.js:497:10) [DEBUG] : at startup (node.js:119:16) [DEBUG] : at node.js:935:3 [ERROR] : Alloy compiler failed TRACE | titanium exited with exit code 1 ERROR | Error: ti run exited with error code 1 at ChildProcess. (/Users/christinevi/.appcelerator/install/5.0.2/package/node_modules/appc-cli-titanium/plugins/run.js:89:66) at ChildProcess.emit (events.js:117:20) at Process.ChildProcess._handle.onexit (child_process.js:820:12)

Comments

  1. Christi 2015-10-13

    Actually I think this can be closed. I revisited and was able to make it work. Sample: {{ }} Then later when creating the row, the old way (without attributed string): {{ nameLabel: _.extend({ text: "asdf" }); }} New way with attributed string: {{ var attr = Ti.UI.createAttributedString({ text: event.name, attributes: [ { type: Titanium.UI.ATTRIBUTE_BACKGROUND_COLOR, value: "red", range: [0, event.name.length] } ] }); nameLabel: _.extend({ attributedString: attr }) }} I'm not sure how to close the bug (or I cannot). Sorry about that!

JSON Source