1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    23
    Vote Rating
    0
    robertocarvajal is on a distinguished road

      0  

    Default Problem with Ext.XTemplate escaping javascript functions

    Problem with Ext.XTemplate escaping javascript functions


    I have a xtpl config that needs to include some custom javascript, so I'm doing something like this:

    Code:
    tpl: {
    '<tpl>my template stuff <script>function test() { // some javascript }</script></tpl>'
    }
    the template loads like this

    Code:
    my template stuff <script>function test()
    even escaping the { like this \{ it doesn't work, does anyone has a clue how to escape { inside XTemplate?

    thanks!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,112
    Vote Rating
    470
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Have a look at the following:
    http://docs.sencha.com/ext-js/4-0/#!/api/Ext.XTemplate

    Functions are supported.

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Jul 2007
    Location
    Sydney Australia
    Posts
    7
    Vote Rating
    3
    jamesmoey is on a distinguished road

      2  

    Default


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

  4. #4
    Sencha User
    Join Date
    Sep 2008
    Posts
    23
    Vote Rating
    0
    robertocarvajal is on a distinguished road

      0  

    Default


    I realized it's nonsense to embed JS in a template since functions are supported and since you can load external JS too, I was just trying to use some custom code for a html5 player and got surprised it just didn't work right away, thanks for the help!

  5. #5
    Ext JS Premium Member devtig's Avatar
    Join Date
    Jan 2010
    Location
    Rotterdam, The Netherlands
    Posts
    389
    Vote Rating
    13
    devtig will become famous soon enough

      0  

    Default


    Quote Originally Posted by jamesmoey View Post
    Try "{['{']}" and "{['}']}"
    I can confirm that this works.

    PS: I dont use functions in the template but just curly braces.