Opened 10 years ago
Last modified 10 years ago
#14978 closed enhancement
Dojo parser: parsing comma-separated elements into an array should support a way to escape commas inside elements — at Version 2
Reported by: | Adrian Vasiliu | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | tbd |
Component: | Parser | Version: | 1.7.2 |
Keywords: | Cc: | cjolif | |
Blocked By: | Blocking: |
Description (last modified by )
Various widgets have properties of type Array that can be specified in mark-up using strings. For example, one can specify
<div data-dojo-type="dojox.mobile.SpinWheelSlot?"
labels="'a','b'" ...>
or <div data-dojo-type="dojox.mobile.SpinWheelSlot?"
labels="a,b" ...>
The Dojo parser transforms these comma-separated strings into an array of 2 elements (this holds for both dojo/parser and dojox/mobile/parser).
So far so good, but it seems there's currently no easy way to include a comma in an element. Say, if we need an array of 2 elements, "a,A" and "b,B", specifying
<div data-dojo-type="dojox.mobile.SpinWheelSlot?"
labels="'a,A','b,B'" ...>
the parsed array contains 4, not 2 elements.
The following attempts to escape the comma character do not work either:
<div data-dojo-type="dojox.mobile.SpinWheelSlot?"
labels="'a\,A','b\,B'" ...>
<div data-dojo-type="dojox.mobile.SpinWheelSlot?"
labels="'a,A','b,B'" ...>
How to reproduce:
- Unzip the attached testParser.zip, say into the parent folder of dojo and dijit (otherwise, adapt the paths in test.html). This contains test.html which includes in mark-up three occurrences of a dijit widget defined in TestWidget?.js, using different ways to define an array of 2 elements each containing a comma.
- Run test/test.html
=> The console shows the elements of the parsed arrays. In all cases, the array has 4, not 2 elements.
Change History (3)
Changed 10 years ago by
comment:1 Changed 10 years ago by
Cc: | cjolif added |
---|---|
Component: | General → Parser |
Owner: | set to bill |
comment:2 Changed 10 years ago by
Description: | modified (diff) |
---|
Sample for reproducing.