Success! Looks like we've fixed this one. According to our records the fix was applied for DSGNR-1852 in a recent build.
  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    117
    Vote Rating
    11
    Sottilde will become famous soon enough

      0  

    Default 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:

    Code:
    <div>
      <span class="number">
        {deadline:getTimeSpanNumber()}
      </span> 
      <span class="label">
        {deadline:getTimeSpanLabel()}
      </span>
    </div>
    I have extended Ext.util.Format to add these functions.

    The above code throws a parse error in the latest build of Architect.

    The error reads:
    Invalid tpl: Parse error

    ... (snip) copy of TPL above ...

    Source Class: xds.component.config.Template
    Source Method: normalizeValue
    However, the following equivalent code does not throw a parse error and works as expected:
    Code:
    <div>
      <span class="number">
        {deadline:getTimeSpanNumber()}
      </span> 
      <span class="label">
        {[Ext.util.Format.getTimeSpanLabel(values.fundingDeadline)]}
      </span>
    </div>

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    117
    Vote Rating
    11
    Sottilde will become famous soon enough

      0  

    Default


    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:

    Code:
    Money: {price:usMoney()} Money2: {fee.usMoney()}
    I must instead do:

    Code:
    Money: {price.usMoney()} Money2: {[Ext.util.Format.usMoney(values.price)]}
    Any other calls to usMoney() in the entire TPL, if not wrapped in {[]}, causes a parse error in Architect.

  3. #3
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,445
    Vote Rating
    129
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Scott - we're looking into this one.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #4
    Sencha User jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    567
    Vote Rating
    20
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    Is your project an Ext JS project or a Sencha Touch project?
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    117
    Vote Rating
    11
    Sottilde will become famous soon enough

      0  

    Default


    ExtJS.

  6. #6
    Sencha User jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    567
    Vote Rating
    20
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    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

  7. #7
    Sencha User jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    567
    Vote Rating
    20
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    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. #8
    Sencha User
    Join Date
    Feb 2012
    Posts
    117
    Vote Rating
    11
    Sottilde will become famous soon enough

      0  

    Default


    Quote Originally Posted by jjohnston View Post
    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?
    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.

Thread Participants: 2