-
19 Apr 2012 1:54 PM #1
TPL Parse Error when calling more than one function on a value
TPL Parse Error when calling more than one function on a value
I have an interesting situation where, for visual reasons, I want to run two different functions on a date to extract different parts of it and style them differently. My code is much like the following:
I have extended Ext.util.Format to add these functions.Code:<div> <span class="number"> {deadline:getTimeSpanNumber()} </span> <span class="label"> {deadline:getTimeSpanLabel()} </span> </div>
The above code throws a parse error in the latest build of Architect.
The error reads:
However, the following equivalent code does not throw a parse error and works as expected:Invalid tpl: Parse error
... (snip) copy of TPL above ...
Source Class: xds.component.config.Template
Source Method: normalizeValue
Code:<div> <span class="number"> {deadline:getTimeSpanNumber()} </span> <span class="label"> {[Ext.util.Format.getTimeSpanLabel(values.fundingDeadline)]} </span> </div>
-
2 May 2012 11:29 AM #2
This issue is getting to be more and more annoying and is breaking major functionality in my app, as well as causing me to lose hair.
Using multiple format calls in a single TPL always results in parse errors. I cannot do something like:
I must instead do:Code:Money: {price:usMoney()} Money2: {fee.usMoney()}
Any other calls to usMoney() in the entire TPL, if not wrapped in {[]}, causes a parse error in Architect.Code:Money: {price.usMoney()} Money2: {[Ext.util.Format.usMoney(values.price)]}
-
3 May 2012 1:09 PM #3
Scott - we're looking into this one.
Aaron Conran
@aconran
Sencha Architect Development Team
-
8 May 2012 9:58 AM #4
Is your project an Ext JS project or a Sencha Touch project?
Jason Johnston
@lojjic
Sencha Architect Development Team
-
8 May 2012 10:36 AM #5
-
8 May 2012 10:56 AM #6
Interesting, it appears that Ext JS 4.0.7's own XTemplate parser rejects these examples... for instance I created a blank Ext JS app and ran the following in onReady:
Ext.create('Ext.XTemplate', 'Money: {price:usMoney()} Money2: {fee.usMoney()}')
This results in the same parsing error that you see within Architect, which makes sense because we use Ext's own XTemplate implementation to do the parsing for validation.
This definitely seems like a bug, but it seems like a bug in the Ext JS framework itself, and that Architect is doing the right thing in warning you about it up front.Jason Johnston
@lojjic
Sencha Architect Development Team
-
8 May 2012 11:14 AM #7
Reading it again more carefully I noticed there was a syntax error in that particular example, should have been fee:usMoney() rather than fee.usMoney().
However even after fixing that the problem still persists. I went to the API docs and noticed that in the example code in the Template class, they do not include the parens after the formatting method if it does not have arguments, so:
'Money: {price:usMoney} Money2: {fee:usMoney}'
This does, in fact, work in both a standalone Ext app and within Architect. Perhaps this is just a quirk of the template syntax where it does not like empty open-close parens?Jason Johnston
@lojjic
Sencha Architect Development Team
-
8 May 2012 12:12 PM #8
Good catch! It seems that in ExtJS 4.1 the template I provided does in fact work correctly in a console test, even with the empty parens.
Removing the empty parens works for me. It seems that the first empty parens throws something off in the parsing that makes any second call with empty parens fail.
I suppose this bug will resolve itself once Architect upgrades to 4.1.
Success! Looks like we've fixed this one. According to our records the fix was applied for
DSGNR-1852
in
Architect 2.1.


Reply With Quote