-
30 Jan 2012 11:09 AM #1
[4.1.0 beta 2] Error in XTemplate output if text contains { and }
[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
output : TypeError: Cannot read property 'type' of undefinedCode:Ext.create('Ext.XTemplate','function {name}(){}').apply({name:'ben'})
output: worksCode:Ext.create('Ext.XTemplate','function {name}()').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}(){{ return 20;}}').apply({name:'ben'})
TypeError: Cannot read property 'type' of undefinedCode:Ext.create('Ext.XTemplate','function {name}(){{}}').apply({name:'ben'})
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.
-
30 Jan 2012 11:44 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
This sounds like why you can't use > in an if... because it means something. You have to use >
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Jan 2012 11:56 AM #3
Not following. There is no > in my code.
Did you mean } ?
-
30 Jan 2012 12:02 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Was an example that is in the documentation.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Jan 2012 12:20 PM #5
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.
-
3 Feb 2012 2:19 PM #6
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.
-
30 Mar 2012 7:01 AM #7
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.
-
30 Mar 2012 9:23 AM #8
Well, I tried
Got the error:PHP Code:Ext.create('Ext.XTemplate','function {name}()\u007B \u007D').apply({name:'ben'})
I used google chrome. 4.1.0rc1PHP Code:TypeError: Cannot read property '1' of null
-
6 Jun 2012 10:42 PM #9
Try "{['{']}" and "{['}']}"


Reply With Quote