| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | var ChunkTemplate = require("./ChunkTemplate"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function JsonpChunkTemplate(outputOptions) { | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	ChunkTemplate.call(this, outputOptions); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | module.exports = JsonpChunkTemplate; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | JsonpChunkTemplate.prototype = Object.create(ChunkTemplate.prototype); | 
					
						
							|  |  |  | JsonpChunkTemplate.prototype.renderHeader = function(chunk) { | 
					
						
							|  |  |  | 	var buf = ChunkTemplate.prototype.renderHeader.call(this, chunk); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	var jsonpFunction = this.outputOptions.jsonpFunction || ("webpackJsonp" + (this.outputOptions.library || "")); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	buf.unshift(jsonpFunction + "(" + JSON.stringify(chunk.ids) + ","); | 
					
						
							|  |  |  | 	return buf; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | JsonpChunkTemplate.prototype.renderFooter = function(chunk) { | 
					
						
							|  |  |  | 	var buf = ChunkTemplate.prototype.renderFooter.call(this, chunk); | 
					
						
							|  |  |  | 	buf.push(")"); | 
					
						
							|  |  |  | 	return buf; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | JsonpChunkTemplate.prototype.updateHash = function(hash) { | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	ChunkTemplate.prototype.updateHash.call(this, hash); | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 	hash.update("JsonpChunkTemplate"); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	hash.update("3"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	hash.update(this.outputOptions.jsonpFunction + ""); | 
					
						
							|  |  |  | 	hash.update(this.outputOptions.library + ""); | 
					
						
							|  |  |  | }; |