Results 1 to 9 of 9

Thread: [4.1.0 beta 2] Error in XTemplate output if text contains { and }

  1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    96
    Vote Rating
    0
      0  

    Question [4.1.0 beta 2] Error in XTemplate output if text contains { and }

    Hi all,
    Ext.XTemplate is giving interesting output when used with text that contains {} Below are the code and responses

    Code:
    Ext.create('Ext.XTemplate','function {name}(){}').apply({name:'ben'})
    output : TypeError: Cannot read property 'type' of undefined

    Code:
    Ext.create('Ext.XTemplate','function {name}()').apply({name:'ben'})
    output: works

    Code:
    Ext.create('Ext.XTemplate','function {name}(){ return 20;}').apply({name:'ben'})
    output: "function ben()"

    Code:
    Ext.create('Ext.XTemplate','function {name}(){{ return 20;}}').apply({name:'ben'})
    "function ben(){}"

    Code:
    Ext.create('Ext.XTemplate','function {name}(){{ return 20;}}').apply({name:'ben'})
    "function ben(){}"

    Code:
    Ext.create('Ext.XTemplate','function {name}(){{}}').apply({name:'ben'})
    TypeError: Cannot read property 'type' of undefined


    1. Is this a bug?
    2. If not, how do you use XTemplate for expand text containing such data?
    3. How do I get around this?

    regards.

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1381
      0  

    Default

    This sounds like why you can't use > in an if... because it means something. You have to use >
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    96
    Vote Rating
    0
      0  

    Question

    Not following. There is no > in my code.
    Did you mean } ?

  4. #4
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1381
      0  

    Default

    Was an example that is in the documentation.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Jul 2008
    Posts
    96
    Vote Rating
    0
      0  

    Default

    I just searched the documentation for XTemplate. I could find not such thing. Can you please point me to the section so I can just search for it.

    I have seen the one on >. That is not what I'm using. The issue I'm having has to do with { and }. In .NET, we used {{ and }} for the literal. Tried that, as you can see from the initial code, but it did not work.

  6. #6
    Sencha User
    Join Date
    Jul 2008
    Posts
    96
    Vote Rating
    0
      0  

    Default

    Haven't heard anything else about this.
    Is this an error? Am I doing something wrong?
    I ended up using _.tempate which uses <%= %>. It works but I do prefer the {} syntax used by extjs.

  7. #7
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,026
    Vote Rating
    108
      0  

    Default

    Just stumbled upon this... I think what Mitchell is saying is that the curly braces need to be escaped.

    You tried using \u007B and \u007D for { and } respectively?
    Product Architect
    Altus Ltd.

  8. #8
    Sencha User
    Join Date
    Jul 2008
    Posts
    96
    Vote Rating
    0
      0  

    Default

    Well, I tried

    PHP Code:
    Ext.create('Ext.XTemplate','function {name}()\u007B \u007D').apply({name:'ben'}) 
    Got the error:
    PHP Code:
    TypeErrorCannot read property '1' of null 
    I used google chrome. 4.1.0rc1

  9. #9
    Sencha User
    Join Date
    Jul 2007
    Location
    Sydney Australia
    Posts
    7
    Vote Rating
    3
      1  

    Default

    Try "{['{']}" and "{['}']}"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •