Debian Codegraph @

dojox/dtl/tag/date.js

raw symbols SCIP
1 define([
2 "dojo/_base/lang",
3 "../_base",
4 "../utils/date"
5 ], function(lang,dd,ddud){
6
7 var date = lang.getObject("tag.date", true, dd);
8 /*=====
9 date = {
10 // TODO: summary
11 };
12 =====*/
13
14 date.NowNode = function(format, node){
15 this._format = format;
16 this.format = new ddud.DateFormat(format);
17 this.contents = node;
18 };
19 lang.extend(date.NowNode, {
20 render: function(context, buffer){
21 this.contents.set(this.format.format(new Date()));
22 return this.contents.render(context, buffer);
23 },
24 unrender: function(context, buffer){
25 return this.contents.unrender(context, buffer);
26 },
27 clone: function(buffer){
28 return new this.constructor(this._format, this.contents.clone(buffer));
29 }
30 });
31
32 date.now = function(parser, token){
33 // Split by either :" or :'
34 var parts = token.split_contents();
35 if(parts.length != 2){
36 throw new Error("'now' statement takes one argument");
37 }
38 return new date.NowNode(parts[1].slice(1, -1), parser.create_text_node());
39 };
40
41 return date;
42 });