var marked = require('marked');

function TemplateParam(page, param) {
	this.page = page;
	this.site = page.site;
	this.root = page.site.root;
	for (var key in param) {
		if (key != 'page' && !this[key] && param.hasOwnProperty(key)) {
			this[key] = param[key];
		}
	}
}

TemplateParam.prototype = {
	isActive: function(page) {
		return page == this._activePage;
	},

	markdown: function(string) {
		return string ? marked(string) : '';
	},

	render: function(template, page, param) {
		for (var key in param)
			this[key] = param[key];
		return (page || this.page)._renderTemplate(template, this);
	},

	paginate: function(collection, perPage) {
		return collection.paginate(this.number, perPage);
	}
};

module.exports = TemplateParam;
@@ -64,16 +64,36 @@
 aram) %7B%0A
+%09param.page = page;%0A
 %09this.pa
@@ -161,132 +161,27 @@
 t;%0A%09
-for (var key in param) %7B%0A%09%09if (key != 'page' && !this%5Bkey%5D && param.hasOwnProperty(key)) %7B%0A%09%09%09this%5Bkey%5D = param%5Bkey%5D;%0A%09%09%7D%0A%09%7D
+this.param = param;
 %0A%7D%0A%0A
@@ -258,16 +258,22 @@
 == this.
+param.
 _activeP
@@ -282,16 +282,120 @@
 e;%0A%09%7D,%0A%0A
+%09inPath: function(page) %7B%0A%09%09return this.isActive(page) %7C%7C page.isAncestor(this.param._activePage);%0A%09%7D,%0A%0A
 %09markdow
@@ -507,60 +507,8 @@
 ) %7B%0A
-%09%09for (var key in param)%0A%09%09%09this%5Bkey%5D = param%5Bkey%5D;%0A
 %09%09re
@@ -536,16 +536,9 @@
 ge).
-_renderT
+t
 empl
@@ -551,20 +551,35 @@
 mplate, 
-this
+param %7C%7C this.param
 );%0A%09%7D,%0A%0A
@@ -655,16 +655,22 @@
 te(this.
+param.
 number, 

Implement TemplateParam#param.