function(position) {
		if(!this.templateNodes[0]) {
			// fill element.innerHTML with the template
			//this.domElement.innerHTML = this.template;
			htmlToElem(this.domElement, this.template);
			
			// save template nodes
			this.templateNodes.push(Array.prototype.slice.call(this.domElement.childNodes));
			
			return;
		}
		
		/*var clonedNode, clonedNodes = [];
		var templateNodes = this.templateNodes[0]; // need to be changed, because this.templateNodes[0] doesn't have to exist.
		
		if(position == null || position == this.templateNodes.length) {
			// insert at the end
			for(var i = 0; i < templateNodes.length; i++) {
				clonedNode = templateNodes[i].cloneNode(true);
				this.domElement.appendChild(clonedNode);
				clonedNodes.push(clonedNode);
			}
			
			this.templateNodes.push(clonedNodes);
		}
		else {
			// insert at the position (before nodes of this.templateNodes[position])
			for(var i = 0; i < templateNodes.length; i++) {
				clonedNode = templateNodes[i].cloneNode(true);
				this.domElement.insertBefore(clonedNode, this.templateNodes[position][0]);
				clonedNodes.push(clonedNode);
			}
			
			this.templateNodes.splice(position, 0, clonedNodes);
		}*/
		
		var dummyWrapper = document.createElement("div");
		//dummyWrapper.innerHTML = this.template;
		htmlToElem(dummyWrapper, this.template);
		
		var templateNodes = Array.prototype.slice.call(dummyWrapper.childNodes);
		
		if(position == null || position == this.templateNodes.length) {
			// insert at the end
			for(var i = 0; i < templateNodes.length; i++) {
				this.domElement.appendChild(templateNodes[i]);
			}
			
			this.templateNodes.push(templateNodes);
		}
		else {
			// insert at the position (before nodes of this.templateNodes[position])
			for(var i = 0; i < templateNodes.length; i++) {
				this.domElement.insertBefore(templateNodes[i], this.templateNodes[position][0]);
			}
			
			this.templateNodes.splice(position, 0, templateNodes);
		}
	}
function(position) {
		if(!this.templateNodes[0]) {
			
			
			htmlToElem(this.domElement, this.template);
			
			
			this.templateNodes.push(Array.prototype.slice.call(this.domElement.childNodes));
			
			return;
		}
		
		
		
		var dummyWrapper = document.createElement("div");
		
		htmlToElem(dummyWrapper, this.template);
		
		var templateNodes = Array.prototype.slice.call(dummyWrapper.childNodes);
		
		if(position == null || position == this.templateNodes.length) {
			
			for(var i = 0; i < templateNodes.length; i++) {
				this.domElement.appendChild(templateNodes[i]);
			}
			
			this.templateNodes.push(templateNodes);
		}
		else {
			
			for(var i = 0; i < templateNodes.length; i++) {
				this.domElement.insertBefore(templateNodes[i], this.templateNodes[position][0]);
			}
			
			this.templateNodes.splice(position, 0, templateNodes);
		}
	}
function ( position ) { if ( ! this . templateNodes [ 0 ] ) { // fill element.innerHTML with the template //this.domElement.innerHTML = this.template; htmlToElem ( this . domElement , this . template ) ; // save template nodes this . templateNodes . push ( Array . prototype . slice . call ( this . domElement . childNodes ) ) ; return ; } /*var clonedNode, clonedNodes = [];
		var templateNodes = this.templateNodes[0]; // need to be changed, because this.templateNodes[0] doesn't have to exist.
		
		if(position == null || position == this.templateNodes.length) {
			// insert at the end
			for(var i = 0; i < templateNodes.length; i++) {
				clonedNode = templateNodes[i].cloneNode(true);
				this.domElement.appendChild(clonedNode);
				clonedNodes.push(clonedNode);
			}
			
			this.templateNodes.push(clonedNodes);
		}
		else {
			// insert at the position (before nodes of this.templateNodes[position])
			for(var i = 0; i < templateNodes.length; i++) {
				clonedNode = templateNodes[i].cloneNode(true);
				this.domElement.insertBefore(clonedNode, this.templateNodes[position][0]);
				clonedNodes.push(clonedNode);
			}
			
			this.templateNodes.splice(position, 0, clonedNodes);
		}*/ var dummyWrapper = document . createElement ( "div" ) ; //dummyWrapper.innerHTML = this.template; htmlToElem ( dummyWrapper , this . template ) ; var templateNodes = Array . prototype . slice . call ( dummyWrapper . childNodes ) ; if ( position == null || position == this . templateNodes . length ) { // insert at the end for ( var i = 0 ; i < templateNodes . length ; i ++ ) { this . domElement . appendChild ( templateNodes [ i ] ) ; } this . templateNodes . push ( templateNodes ) ; } else { // insert at the position (before nodes of this.templateNodes[position]) for ( var i = 0 ; i < templateNodes . length ; i ++ ) { this . domElement . insertBefore ( templateNodes [ i ] , this . templateNodes [ position ] [ 0 ] ) ; } this . templateNodes . splice ( position , 0 , templateNodes ) ; } }
Clone template nodes at the specified position. If ommited, template is cloned at the end.
Clone template nodes at the specified position . If ommited template is cloned at the end .