Properties Methods Events Config Options Direct Link

Class Ext.Template

Package:Ext
Defined In:Template.js
Class:Template
Subclasses:XTemplate
Extends:Object

Represents an HTML fragment template. Templates may be precompiled for greater performance.

An instance of this class may be created by passing to the constructor either a single argument, or multiple arguments:
  • single argument : String/Array
    The single argument may be either a String or an Array:
    • String :
    • var t = new Ext.Template("<div>Hello {0}.</div>");
      t.append('some-element', ['foo']);
    • Array :
    • An Array will be combined with join('').
      var t = new Ext.Template([
          '<div name="{id}">',
              '<span class="{cls}">{name:trim} {value:ellipsis(10)}</span>',
          '</div>',
      ]);
      t.compile();
      t.append('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'});
  • multiple arguments : String, Object, Array, ...
    Multiple arguments will be combined with join('').
    var t = new Ext.Template(
        '<div name="{id}">',
            '<span class="{cls}">{name} {value}</span>',
        '</div>',
        // a configuration object:
        {
            compiled: true,      // compile immediately
        }
    );

    Notes:

    • Formatting and disableFormats are not applicable for Sencha Touch.
    • For a list of available format functions, see Ext.util.Format.
    • disableFormats reduces apply time when no formatting is required.

Config Options

Config OptionsDefined By

Public Properties

This class has no public properties.

Public Methods

MethodDefined By

Public Events

This class has no public events.