src/index.js
function processContent(target, opt, tagsRegExp, listOfFiles) {
	let targetContent = String(target.contents);
	const targetPath = target.path;
	const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);

	// recursively process files
	files.forEach(function (fileData) {
		if (listOfFiles.indexOf(fileData.file.path) !== -1) {
			throw error("Circular definition found. File: " + fileData.file.path + " referenced in a child file.");
		}
		listOfFiles.push(fileData.file.path);
		const content = processContent(fileData.file, opt, tagsRegExp, listOfFiles);
		listOfFiles.pop();

		targetContent = inject(targetContent, String(content), opt, fileData.tags);
	});
	if (listOfFiles.length === 1 && !opt.quiet && files.length) {
		log(
			colors.cyan(files.length.toString()) +
			' partials injected into ' +
			colors.magenta(targetPath) +
			'.');
	}
	return new Buffer.from(targetContent);
}
function processContent(target, opt, tagsRegExp, listOfFiles) {
	let targetContent = String(target.contents);
	const targetPath = target.path;
	const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);

	// recursively process files
	files.forEach(function (fileData) {
		if (listOfFiles.indexOf(fileData.file.path) !== -1) {
			throw error("Circular definition found. File: " + fileData.file.path + " referenced in a child file.");
		}
		listOfFiles.push(fileData.file.path);
		const content = processContent(fileData.file, opt, tagsRegExp, listOfFiles);
		listOfFiles.pop();

		targetContent = inject(targetContent, String(content), opt, fileData.tags);
	});
	if (listOfFiles.length === 1 && !opt.quiet && files.length) {
		log(
			colors.cyan(files.length.toString()) +
			' partials injected into ' +
			colors.magenta(targetPath) +
			'.');
	}
	return new Buffer.from(targetContent);
}
function processContent ( target , opt , tagsRegExp , listOfFiles ) { let targetContent = String ( target . contents ) ; const targetPath = target . path ; const files = extractFilePaths ( targetContent , targetPath , opt , tagsRegExp ) ; // recursively process files files . forEach ( function ( fileData ) { if ( listOfFiles . indexOf ( fileData . file . path ) !== - 1 ) { throw error ( "Circular definition found. File: " + fileData . file . path + " referenced in a child file." ) ; } listOfFiles . push ( fileData . file . path ) ; const content = processContent ( fileData . file , opt , tagsRegExp , listOfFiles ) ; listOfFiles . pop ( ) ; targetContent = inject ( targetContent , String ( content ) , opt , fileData . tags ) ; } ) ; if ( listOfFiles . length === 1 && ! opt . quiet && files . length ) { log ( colors . cyan ( files . length . toString ( ) ) + ' partials injected into ' + colors . magenta ( targetPath ) + '.' ) ; } return new Buffer . from ( targetContent ) ; }
Parse content and create new template
with all injections made

@param {Object} target
@param {Object} opt
@param {Object} tagsRegExp
@param {Array} listOfFiles
@returns {Buffer}
Parse content and create new template with all injections made