Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.dtl.tag.misc"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.dtl.tag.misc"] = true;
3
dojo.provide("dojox.dtl.tag.misc");
4
 
5
dojo.require("dojox.dtl._base");
6
 
7
dojox.dtl.tag.misc.commentNode = new function(){
8
	this.render = this.unrender = function(context, buffer){ return buffer; };
9
	this.clone = function(){ return this; };
10
	this.toString = function(){ return "dojox.dtl.tag.misc.CommentNode"; };
11
}
12
 
13
dojox.dtl.tag.misc.DebugNode = function(TextNode){
14
	this._TextNode = TextNode;
15
}
16
dojo.extend(dojox.dtl.tag.misc.DebugNode, {
17
	render: function(context, buffer){
18
		var keys = context.getKeys();
19
		var debug = "";
20
		for(var i = 0, key; key = keys[i]; i++){
21
			console.debug("DEBUG", key, ":", context[key]);
22
			debug += key + ": " + dojo.toJson(context[key]) + "\n\n";
23
		}
24
		return new this._TextNode(debug).render(context, buffer, this);
25
	},
26
	unrender: function(context, buffer){
27
		return buffer;
28
	},
29
	clone: function(buffer){
30
		return new this.constructor(this._TextNode);
31
	},
32
	toString: function(){ return "dojox.dtl.tag.misc.DebugNode"; }
33
});
34
 
35
dojox.dtl.tag.misc.FilterNode = function(varnode, nodelist){
36
	this._varnode = varnode;
37
	this._nodelist = nodelist;
38
}
39
dojo.extend(dojox.dtl.tag.misc.FilterNode, {
40
	render: function(context, buffer){
41
		// Doing this in HTML requires a different buffer with a fake root node
42
		var output = this._nodelist.render(context, new dojox.string.Builder());
43
		context.update({ "var": output.toString() });
44
		var filtered = this._varnode.render(context, buffer);
45
		context.pop();
46
		return buffer;
47
	},
48
	unrender: function(context, buffer){
49
		return buffer;
50
	},
51
	clone: function(buffer){
52
		return new this.constructor(this._expression, this._nodelist.clone(buffer));
53
	}
54
});
55
 
56
dojox.dtl.tag.misc.comment = function(parser, text){
57
	// summary: Ignore everything between {% comment %} and {% endcomment %}
58
	parser.skipPast("endcomment");
59
	return dojox.dtl.tag.misc.commentNode;
60
}
61
 
62
dojox.dtl.tag.misc.debug = function(parser, text){
63
	// summary: Output the current context, maybe add more stuff later.
64
	return new dojox.dtl.tag.misc.DebugNode(parser.getTextNode());
65
}
66
 
67
dojox.dtl.tag.misc.filter = function(parser, text){
68
	// summary: Filter the contents of the blog through variable filters.
69
	var parts = text.split(" ", 2);
70
	var varnode = new (parser.getVarNode())("var|" + parts[1]);
71
	var nodelist = parser.parse(["endfilter"]);
72
	parser.next();
73
	return new dojox.dtl.tag.misc.FilterNode(varnode, nodelist);
74
}
75
 
76
}