_base.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.dtl._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.dtl._base"] = true;
  8. dojo.provide("dojox.dtl._base");
  9. dojo.require("dojox.string.Builder");
  10. dojo.require("dojox.string.tokenize");
  11. dojo.experimental("dojox.dtl");
  12. (function(){
  13. var dd = dojox.dtl;
  14. dd.TOKEN_BLOCK = -1;
  15. dd.TOKEN_VAR = -2;
  16. dd.TOKEN_COMMENT = -3;
  17. dd.TOKEN_TEXT = 3;
  18. dd._Context = dojo.extend(function(dict){
  19. // summary: Pass one of these when rendering a template to tell the template what values to use.
  20. if(dict){
  21. dojo._mixin(this, dict);
  22. if(dict.get){
  23. // Preserve passed getter and restore prototype get
  24. this._getter = dict.get;
  25. delete this.get;
  26. }
  27. }
  28. },
  29. {
  30. push: function(){
  31. var last = this;
  32. var context = dojo.delegate(this);
  33. context.pop = function(){ return last; }
  34. return context;
  35. },
  36. pop: function(){
  37. throw new Error("pop() called on empty Context");
  38. },
  39. get: function(key, otherwise){
  40. var n = this._normalize;
  41. if(this._getter){
  42. var got = this._getter(key);
  43. if(typeof got != "undefined"){
  44. return n(got);
  45. }
  46. }
  47. if(typeof this[key] != "undefined"){
  48. return n(this[key]);
  49. }
  50. return otherwise;
  51. },
  52. _normalize: function(value){
  53. if(value instanceof Date){
  54. value.year = value.getFullYear();
  55. value.month = value.getMonth() + 1;
  56. value.day = value.getDate();
  57. value.date = value.year + "-" + ("0" + value.month).slice(-2) + "-" + ("0" + value.day).slice(-2);
  58. value.hour = value.getHours();
  59. value.minute = value.getMinutes();
  60. value.second = value.getSeconds();
  61. value.microsecond = value.getMilliseconds();
  62. }
  63. return value;
  64. },
  65. update: function(dict){
  66. var context = this.push();
  67. if(dict){
  68. dojo._mixin(this, dict);
  69. }
  70. return context;
  71. }
  72. });
  73. var smart_split_re = /("(?:[^"\\]*(?:\\.[^"\\]*)*)"|'(?:[^'\\]*(?:\\.[^'\\]*)*)'|[^\s]+)/g;
  74. var split_re = /\s+/g;
  75. var split = function(/*String|RegExp?*/ splitter, /*Integer?*/ limit){
  76. splitter = splitter || split_re;
  77. if(!(splitter instanceof RegExp)){
  78. splitter = new RegExp(splitter, "g");
  79. }
  80. if(!splitter.global){
  81. throw new Error("You must use a globally flagged RegExp with split " + splitter);
  82. }
  83. splitter.exec(""); // Reset the global
  84. var part, parts = [], lastIndex = 0, i = 0;
  85. while(part = splitter.exec(this)){
  86. parts.push(this.slice(lastIndex, splitter.lastIndex - part[0].length));
  87. lastIndex = splitter.lastIndex;
  88. if(limit && (++i > limit - 1)){
  89. break;
  90. }
  91. }
  92. parts.push(this.slice(lastIndex));
  93. return parts;
  94. }
  95. dd.Token = function(token_type, contents){
  96. this.token_type = token_type;
  97. this.contents = new String(dojo.trim(contents));
  98. this.contents.split = split;
  99. this.split = function(){
  100. return String.prototype.split.apply(this.contents, arguments);
  101. }
  102. }
  103. dd.Token.prototype.split_contents = function(/*Integer?*/ limit){
  104. var bit, bits = [], i = 0;
  105. limit = limit || 999;
  106. while(i++ < limit && (bit = smart_split_re.exec(this.contents))){
  107. bit = bit[0];
  108. if(bit.charAt(0) == '"' && bit.slice(-1) == '"'){
  109. bits.push('"' + bit.slice(1, -1).replace('\\"', '"').replace('\\\\', '\\') + '"');
  110. }else if(bit.charAt(0) == "'" && bit.slice(-1) == "'"){
  111. bits.push("'" + bit.slice(1, -1).replace("\\'", "'").replace('\\\\', '\\') + "'");
  112. }else{
  113. bits.push(bit);
  114. }
  115. }
  116. return bits;
  117. }
  118. var ddt = dd.text = {
  119. _get: function(module, name, errorless){
  120. // summary: Used to find both tags and filters
  121. var params = dd.register.get(module, name.toLowerCase(), errorless);
  122. if(!params){
  123. if(!errorless){
  124. throw new Error("No tag found for " + name);
  125. }
  126. return null;
  127. }
  128. var fn = params[1];
  129. var require = params[2];
  130. var parts;
  131. if(fn.indexOf(":") != -1){
  132. parts = fn.split(":");
  133. fn = parts.pop();
  134. }
  135. dojo["require"](require);
  136. var parent = dojo.getObject(require);
  137. return parent[fn || name] || parent[name + "_"] || parent[fn + "_"];
  138. },
  139. getTag: function(name, errorless){
  140. return ddt._get("tag", name, errorless);
  141. },
  142. getFilter: function(name, errorless){
  143. return ddt._get("filter", name, errorless);
  144. },
  145. getTemplate: function(file){
  146. return new dd.Template(ddt.getTemplateString(file));
  147. },
  148. getTemplateString: function(file){
  149. return dojo._getText(file.toString()) || "";
  150. },
  151. _resolveLazy: function(location, sync, json){
  152. if(sync){
  153. if(json){
  154. return dojo.fromJson(dojo._getText(location)) || {};
  155. }else{
  156. return dd.text.getTemplateString(location);
  157. }
  158. }else{
  159. return dojo.xhrGet({
  160. handleAs: (json) ? "json" : "text",
  161. url: location
  162. });
  163. }
  164. },
  165. _resolveTemplateArg: function(arg, sync){
  166. if(ddt._isTemplate(arg)){
  167. if(!sync){
  168. var d = new dojo.Deferred();
  169. d.callback(arg);
  170. return d;
  171. }
  172. return arg;
  173. }
  174. return ddt._resolveLazy(arg, sync);
  175. },
  176. _isTemplate: function(arg){
  177. return (typeof arg == "undefined") || (typeof arg == "string" && (arg.match(/^\s*[<{]/) || arg.indexOf(" ") != -1));
  178. },
  179. _resolveContextArg: function(arg, sync){
  180. if(arg.constructor == Object){
  181. if(!sync){
  182. var d = new dojo.Deferred;
  183. d.callback(arg);
  184. return d;
  185. }
  186. return arg;
  187. }
  188. return ddt._resolveLazy(arg, sync, true);
  189. },
  190. _re: /(?:\{\{\s*(.+?)\s*\}\}|\{%\s*(load\s*)?(.+?)\s*%\})/g,
  191. tokenize: function(str){
  192. return dojox.string.tokenize(str, ddt._re, ddt._parseDelims);
  193. },
  194. _parseDelims: function(varr, load, tag){
  195. if(varr){
  196. return [dd.TOKEN_VAR, varr];
  197. }else if(load){
  198. var parts = dojo.trim(tag).split(/\s+/g);
  199. for(var i = 0, part; part = parts[i]; i++){
  200. dojo["require"](part);
  201. }
  202. }else{
  203. return [dd.TOKEN_BLOCK, tag];
  204. }
  205. }
  206. }
  207. dd.Template = dojo.extend(function(/*String|dojo._Url*/ template, /*Boolean*/ isString){
  208. // template:
  209. // The string or location of the string to
  210. // use as a template
  211. var str = isString ? template : ddt._resolveTemplateArg(template, true) || "";
  212. var tokens = ddt.tokenize(str);
  213. var parser = new dd._Parser(tokens);
  214. this.nodelist = parser.parse();
  215. },
  216. {
  217. update: function(node, context){
  218. // node: DOMNode|String|dojo.NodeList
  219. // A node reference or set of nodes
  220. // context: dojo._Url|String|Object
  221. // The context object or location
  222. return ddt._resolveContextArg(context).addCallback(this, function(contextObject){
  223. var content = this.render(new dd._Context(contextObject));
  224. if(node.forEach){
  225. node.forEach(function(item){
  226. item.innerHTML = content;
  227. });
  228. }else{
  229. dojo.byId(node).innerHTML = content;
  230. }
  231. return this;
  232. });
  233. },
  234. render: function(context, /*concatenatable?*/ buffer){
  235. buffer = buffer || this.getBuffer();
  236. context = context || new dd._Context({});
  237. return this.nodelist.render(context, buffer) + "";
  238. },
  239. getBuffer: function(){
  240. dojo.require("dojox.string.Builder");
  241. return new dojox.string.Builder();
  242. }
  243. });
  244. var qfRe = /\{\{\s*(.+?)\s*\}\}/g;
  245. dd.quickFilter = function(str){
  246. if(!str){
  247. return new dd._NodeList();
  248. }
  249. if(str.indexOf("{%") == -1){
  250. return new dd._QuickNodeList(dojox.string.tokenize(str, qfRe, function(token){
  251. return new dd._Filter(token);
  252. }));
  253. }
  254. }
  255. dd._QuickNodeList = dojo.extend(function(contents){
  256. this.contents = contents;
  257. },
  258. {
  259. render: function(context, buffer){
  260. for(var i=0, l=this.contents.length; i<l; i++){
  261. if(this.contents[i].resolve){
  262. buffer = buffer.concat(this.contents[i].resolve(context));
  263. }else{
  264. buffer = buffer.concat(this.contents[i]);
  265. }
  266. }
  267. return buffer;
  268. },
  269. dummyRender: function(context){ return this.render(context, dd.Template.prototype.getBuffer()).toString(); },
  270. clone: function(buffer){ return this; }
  271. });
  272. dd._Filter = dojo.extend(function(token){
  273. // summary: Uses a string to find (and manipulate) a variable
  274. if(!token) throw new Error("Filter must be called with variable name");
  275. this.contents = token;
  276. var cache = this._cache[token];
  277. if(cache){
  278. this.key = cache[0];
  279. this.filters = cache[1];
  280. }else{
  281. this.filters = [];
  282. dojox.string.tokenize(token, this._re, this._tokenize, this);
  283. this._cache[token] = [this.key, this.filters];
  284. }
  285. },
  286. {
  287. _cache: {},
  288. _re: /(?:^_\("([^\\"]*(?:\\.[^\\"])*)"\)|^"([^\\"]*(?:\\.[^\\"]*)*)"|^([a-zA-Z0-9_.]+)|\|(\w+)(?::(?:_\("([^\\"]*(?:\\.[^\\"])*)"\)|"([^\\"]*(?:\\.[^\\"]*)*)"|([a-zA-Z0-9_.]+)|'([^\\']*(?:\\.[^\\']*)*)'))?|^'([^\\']*(?:\\.[^\\']*)*)')/g,
  289. _values: {
  290. 0: '"', // _("text")
  291. 1: '"', // "text"
  292. 2: "", // variable
  293. 8: '"' // 'text'
  294. },
  295. _args: {
  296. 4: '"', // :_("text")
  297. 5: '"', // :"text"
  298. 6: "", // :variable
  299. 7: "'"// :'text'
  300. },
  301. _tokenize: function(){
  302. var pos, arg;
  303. for(var i = 0, has = []; i < arguments.length; i++){
  304. has[i] = (typeof arguments[i] != "undefined" && typeof arguments[i] == "string" && arguments[i]);
  305. }
  306. if(!this.key){
  307. for(pos in this._values){
  308. if(has[pos]){
  309. this.key = this._values[pos] + arguments[pos] + this._values[pos];
  310. break;
  311. }
  312. }
  313. }else{
  314. for(pos in this._args){
  315. if(has[pos]){
  316. var value = arguments[pos];
  317. if(this._args[pos] == "'"){
  318. value = value.replace(/\\'/g, "'");
  319. }else if(this._args[pos] == '"'){
  320. value = value.replace(/\\"/g, '"');
  321. }
  322. arg = [!this._args[pos], value];
  323. break;
  324. }
  325. }
  326. // Get a named filter
  327. var fn = ddt.getFilter(arguments[3]);
  328. if(!dojo.isFunction(fn)) throw new Error(arguments[3] + " is not registered as a filter");
  329. this.filters.push([fn, arg]);
  330. }
  331. },
  332. getExpression: function(){
  333. return this.contents;
  334. },
  335. resolve: function(context){
  336. if(typeof this.key == "undefined"){
  337. return "";
  338. }
  339. var str = this.resolvePath(this.key, context);
  340. for(var i = 0, filter; filter = this.filters[i]; i++){
  341. // Each filter has the function in [0], a boolean in [1][0] of whether it's a variable or a string
  342. // and [1][1] is either the variable name of the string content.
  343. if(filter[1]){
  344. if(filter[1][0]){
  345. str = filter[0](str, this.resolvePath(filter[1][1], context));
  346. }else{
  347. str = filter[0](str, filter[1][1]);
  348. }
  349. }else{
  350. str = filter[0](str);
  351. }
  352. }
  353. return str;
  354. },
  355. resolvePath: function(path, context){
  356. var current, parts;
  357. var first = path.charAt(0);
  358. var last = path.slice(-1);
  359. if(!isNaN(parseInt(first))){
  360. current = (path.indexOf(".") == -1) ? parseInt(path) : parseFloat(path);
  361. }else if(first == '"' && first == last){
  362. current = path.slice(1, -1);
  363. }else{
  364. if(path == "true"){ return true; }
  365. if(path == "false"){ return false; }
  366. if(path == "null" || path == "None"){ return null; }
  367. parts = path.split(".");
  368. current = context.get(parts[0]);
  369. if(dojo.isFunction(current)){
  370. var self = context.getThis && context.getThis();
  371. if(current.alters_data){
  372. current = "";
  373. }else if(self){
  374. current = current.call(self);
  375. }else{
  376. current = "";
  377. }
  378. }
  379. for(var i = 1; i < parts.length; i++){
  380. var part = parts[i];
  381. if(current){
  382. var base = current;
  383. if(dojo.isObject(current) && part == "items" && typeof current[part] == "undefined"){
  384. var items = [];
  385. for(var key in current){
  386. items.push([key, current[key]]);
  387. }
  388. current = items;
  389. continue;
  390. }
  391. if(current.get && dojo.isFunction(current.get) && current.get.safe){
  392. current = current.get(part);
  393. }else if(typeof current[part] == "undefined"){
  394. current = current[part];
  395. break;
  396. }else{
  397. current = current[part];
  398. }
  399. if(dojo.isFunction(current)){
  400. if(current.alters_data){
  401. current = "";
  402. }else{
  403. current = current.call(base);
  404. }
  405. }else if(current instanceof Date){
  406. current = dd._Context.prototype._normalize(current);
  407. }
  408. }else{
  409. return "";
  410. }
  411. }
  412. }
  413. return current;
  414. }
  415. });
  416. dd._TextNode = dd._Node = dojo.extend(function(/*Object*/ obj){
  417. // summary: Basic catch-all node
  418. this.contents = obj;
  419. },
  420. {
  421. set: function(data){
  422. this.contents = data;
  423. return this;
  424. },
  425. render: function(context, buffer){
  426. // summary: Adds content onto the buffer
  427. return buffer.concat(this.contents);
  428. },
  429. isEmpty: function(){
  430. return !dojo.trim(this.contents);
  431. },
  432. clone: function(){ return this; }
  433. });
  434. dd._NodeList = dojo.extend(function(/*Node[]*/ nodes){
  435. // summary: Allows us to render a group of nodes
  436. this.contents = nodes || [];
  437. this.last = "";
  438. },
  439. {
  440. push: function(node){
  441. // summary: Add a new node to the list
  442. this.contents.push(node);
  443. return this;
  444. },
  445. concat: function(nodes){
  446. this.contents = this.contents.concat(nodes);
  447. return this;
  448. },
  449. render: function(context, buffer){
  450. // summary: Adds all content onto the buffer
  451. for(var i = 0; i < this.contents.length; i++){
  452. buffer = this.contents[i].render(context, buffer);
  453. if(!buffer) throw new Error("Template must return buffer");
  454. }
  455. return buffer;
  456. },
  457. dummyRender: function(context){
  458. return this.render(context, dd.Template.prototype.getBuffer()).toString();
  459. },
  460. unrender: function(){ return arguments[1]; },
  461. clone: function(){ return this; },
  462. rtrim: function(){
  463. while(1){
  464. i = this.contents.length - 1;
  465. if(this.contents[i] instanceof dd._TextNode && this.contents[i].isEmpty()){
  466. this.contents.pop();
  467. }else{
  468. break;
  469. }
  470. }
  471. return this;
  472. }
  473. });
  474. dd._VarNode = dojo.extend(function(str){
  475. // summary: A node to be processed as a variable
  476. this.contents = new dd._Filter(str);
  477. },
  478. {
  479. render: function(context, buffer){
  480. var str = this.contents.resolve(context);
  481. if(!str.safe){
  482. str = dd._base.escape("" + str);
  483. }
  484. return buffer.concat(str);
  485. }
  486. });
  487. dd._noOpNode = new function(){
  488. // summary: Adds a no-op node. Useful in custom tags
  489. this.render = this.unrender = function(){ return arguments[1]; }
  490. this.clone = function(){ return this; }
  491. }
  492. dd._Parser = dojo.extend(function(tokens){
  493. // summary: Parser used during initialization and for tag groups.
  494. this.contents = tokens;
  495. },
  496. {
  497. i: 0,
  498. parse: function(/*Array?*/ stop_at){
  499. // summary: Turns tokens into nodes
  500. // description: Steps into tags are they're found. Blocks use the parse object
  501. // to find their closing tag (the stop_at array). stop_at is inclusive, it
  502. // returns the node that matched.
  503. var terminators = {}, token;
  504. stop_at = stop_at || [];
  505. for(var i = 0; i < stop_at.length; i++){
  506. terminators[stop_at[i]] = true;
  507. }
  508. var nodelist = new dd._NodeList();
  509. while(this.i < this.contents.length){
  510. token = this.contents[this.i++];
  511. if(typeof token == "string"){
  512. nodelist.push(new dd._TextNode(token));
  513. }else{
  514. var type = token[0];
  515. var text = token[1];
  516. if(type == dd.TOKEN_VAR){
  517. nodelist.push(new dd._VarNode(text));
  518. }else if(type == dd.TOKEN_BLOCK){
  519. if(terminators[text]){
  520. --this.i;
  521. return nodelist;
  522. }
  523. var cmd = text.split(/\s+/g);
  524. if(cmd.length){
  525. cmd = cmd[0];
  526. var fn = ddt.getTag(cmd);
  527. if(fn){
  528. nodelist.push(fn(this, new dd.Token(type, text)));
  529. }
  530. }
  531. }
  532. }
  533. }
  534. if(stop_at.length){
  535. throw new Error("Could not find closing tag(s): " + stop_at.toString());
  536. }
  537. this.contents.length = 0;
  538. return nodelist;
  539. },
  540. next_token: function(){
  541. // summary: Returns the next token in the list.
  542. var token = this.contents[this.i++];
  543. return new dd.Token(token[0], token[1]);
  544. },
  545. delete_first_token: function(){
  546. this.i++;
  547. },
  548. skip_past: function(endtag){
  549. while(this.i < this.contents.length){
  550. var token = this.contents[this.i++];
  551. if(token[0] == dd.TOKEN_BLOCK && token[1] == endtag){
  552. return;
  553. }
  554. }
  555. throw new Error("Unclosed tag found when looking for " + endtag);
  556. },
  557. create_variable_node: function(expr){
  558. return new dd._VarNode(expr);
  559. },
  560. create_text_node: function(expr){
  561. return new dd._TextNode(expr || "");
  562. },
  563. getTemplate: function(file){
  564. return new dd.Template(file);
  565. }
  566. });
  567. dd.register = {
  568. _registry: {
  569. attributes: [],
  570. tags: [],
  571. filters: []
  572. },
  573. get: function(/*String*/ module, /*String*/ name){
  574. var registry = dd.register._registry[module + "s"];
  575. for(var i = 0, entry; entry = registry[i]; i++){
  576. if(typeof entry[0] == "string"){
  577. if(entry[0] == name){
  578. return entry;
  579. }
  580. }else if(name.match(entry[0])){
  581. return entry;
  582. }
  583. }
  584. },
  585. getAttributeTags: function(){
  586. var tags = [];
  587. var registry = dd.register._registry.attributes;
  588. for(var i = 0, entry; entry = registry[i]; i++){
  589. if(entry.length == 3){
  590. tags.push(entry);
  591. }else{
  592. var fn = dojo.getObject(entry[1]);
  593. if(fn && dojo.isFunction(fn)){
  594. entry.push(fn);
  595. tags.push(entry);
  596. }
  597. }
  598. }
  599. return tags;
  600. },
  601. _any: function(type, base, locations){
  602. for(var path in locations){
  603. for(var i = 0, fn; fn = locations[path][i]; i++){
  604. var key = fn;
  605. if(dojo.isArray(fn)){
  606. key = fn[0];
  607. fn = fn[1];
  608. }
  609. if(typeof key == "string"){
  610. if(key.substr(0, 5) == "attr:"){
  611. var attr = fn;
  612. if(attr.substr(0, 5) == "attr:"){
  613. attr = attr.slice(5);
  614. }
  615. dd.register._registry.attributes.push([attr.toLowerCase(), base + "." + path + "." + attr]);
  616. }
  617. key = key.toLowerCase()
  618. }
  619. dd.register._registry[type].push([
  620. key,
  621. fn,
  622. base + "." + path
  623. ]);
  624. }
  625. }
  626. },
  627. tags: function(/*String*/ base, /*Object*/ locations){
  628. dd.register._any("tags", base, locations);
  629. },
  630. filters: function(/*String*/ base, /*Object*/ locations){
  631. dd.register._any("filters", base, locations);
  632. }
  633. }
  634. var escapeamp = /&/g;
  635. var escapelt = /</g;
  636. var escapegt = />/g;
  637. var escapeqt = /'/g;
  638. var escapedblqt = /"/g;
  639. dd._base.escape = function(value){
  640. // summary: Escapes a string's HTML
  641. return dd.mark_safe(value.replace(escapeamp, '&amp;').replace(escapelt, '&lt;').replace(escapegt, '&gt;').replace(escapedblqt, '&quot;').replace(escapeqt, '&#39;'));
  642. }
  643. dd._base.safe = function(value){
  644. if(typeof value == "string"){
  645. value = new String(value);
  646. }
  647. if(typeof value == "object"){
  648. value.safe = true;
  649. }
  650. return value;
  651. }
  652. dd.mark_safe = dd._base.safe;
  653. dd.register.tags("dojox.dtl.tag", {
  654. "date": ["now"],
  655. "logic": ["if", "for", "ifequal", "ifnotequal"],
  656. "loader": ["extends", "block", "include", "load", "ssi"],
  657. "misc": ["comment", "debug", "filter", "firstof", "spaceless", "templatetag", "widthratio", "with"],
  658. "loop": ["cycle", "ifchanged", "regroup"]
  659. });
  660. dd.register.filters("dojox.dtl.filter", {
  661. "dates": ["date", "time", "timesince", "timeuntil"],
  662. "htmlstrings": ["linebreaks", "linebreaksbr", "removetags", "striptags"],
  663. "integers": ["add", "get_digit"],
  664. "lists": ["dictsort", "dictsortreversed", "first", "join", "length", "length_is", "random", "slice", "unordered_list"],
  665. "logic": ["default", "default_if_none", "divisibleby", "yesno"],
  666. "misc": ["filesizeformat", "pluralize", "phone2numeric", "pprint"],
  667. "strings": ["addslashes", "capfirst", "center", "cut", "fix_ampersands", "floatformat", "iriencode", "linenumbers", "ljust", "lower", "make_list", "rjust", "slugify", "stringformat", "title", "truncatewords", "truncatewords_html", "upper", "urlencode", "urlize", "urlizetrunc", "wordcount", "wordwrap"]
  668. });
  669. dd.register.filters("dojox.dtl", {
  670. "_base": ["escape", "safe"]
  671. });
  672. })();
  673. }