Results 1 to 2 of 2

Thread: Dom Helper Named Parameters in Compiled Templates

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2007
    Vote Rating

    Default Dom Helper Named Parameters in Compiled Templates

    Do named parameters work with compiled dom templates? I've run the examples using named parameters and included the additional .compile statement but it complains that the parameters aren't defined (for your blog post one, it specifically says id is not defined, which is the first parameter). If you turn off the compile function everything runs smoothly. Using numbered parameters works fine. I ask because the blog post doesn't say that the compiled ones don't support it. It breaks in both IE and Firefox.

    If it does support it, I'll post some code to see if it's something I'm doing wrong.

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    New York, NY
    Vote Rating


    Named parameters were added as an afterthought and support for them wasn't added to compiled templates (my mistake). Here's a patch that fixes them:

    YAHOO.ext.DomHelper.Template.prototype.compile = function(){
            var html = this.html;
            var re = /\{(\w+)\}/g;
            var body = [];
            body.push("this.compiled = function(values){ return ");
            var result;
            var lastMatchEnd = 0;
            while ((result = re.exec(html)) != null){
                body.push("'", html.substring(lastMatchEnd, result.index), "' + ");
                body.push("values['", html.substring(result.index+1,re.lastIndex-1), "'] + ");
                lastMatchEnd = re.lastIndex;
            body.push("'", html.substr(lastMatchEnd), "';};");
    This will be part of the next release.

Similar Threads

  1. DomHelper Templates not working in IE
    By corey.gilmore in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 8 Feb 2007, 10:03 PM
  2. [solved] how to use the dom helper ???
    By cobalt in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 14 Nov 2006, 9:05 AM
  3. Compiled Templates not working as expected
    By pcbender in forum Ext 1.x: Bugs
    Replies: 5
    Last Post: 20 Oct 2006, 1:08 PM
  4. Dom Helper Reserved Word Hack
    By ojintoad in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 17 Oct 2006, 12:22 PM

Posting Permissions

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