| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var ConcatSource = require("webpack-core/lib/ConcatSource"); | 
					
						
							|  |  |  | var Template = require("./Template"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function ChunkTemplate(outputOptions) { | 
					
						
							|  |  |  | 	Template.call(this, outputOptions); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ChunkTemplate; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ChunkTemplate.prototype = Object.create(Template.prototype); | 
					
						
							|  |  |  | ChunkTemplate.prototype.render = function(chunk, moduleTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 	var source = new ConcatSource(); | 
					
						
							|  |  |  | 	source.add(this.asString(this.renderHeader(chunk))); | 
					
						
							|  |  |  | 	chunk.modules.forEach(function(module, idx) { | 
					
						
							|  |  |  | 		if(idx != 0) source.add(",\n"); | 
					
						
							|  |  |  | 		source.add("\n/***/ " + module.id + ":\n"); | 
					
						
							| 
									
										
										
										
											2013-06-14 21:13:44 +08:00
										 |  |  | 		source.add(moduleTemplate.render(module, dependencyTemplates, chunk)); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | 	source.add("\n\n"); | 
					
						
							|  |  |  | 	source.add(this.asString(this.renderFooter(chunk))); | 
					
						
							| 
									
										
										
										
											2013-05-08 19:28:54 +08:00
										 |  |  | 	chunk.rendered = true; | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	return source; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ChunkTemplate.prototype.renderHeader = function(chunk) { | 
					
						
							|  |  |  | 	return ["{\n"]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ChunkTemplate.prototype.renderFooter = function(chunk) { | 
					
						
							|  |  |  | 	return ["}"]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ChunkTemplate.prototype.updateHash = function(hash) { | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 	hash.update("ChunkTemplate"); | 
					
						
							|  |  |  | 	hash.update("1"); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | }; |