<commit_before>'use strict';

var fs = require('fs');
var _tempatesSrcPath = _paths.src + '/templates';
var _dataPath = _tempatesSrcPath + '/data.json';


gulp.task('_twig', function () {
	return gulp.src(_tempatesSrcPath + '/**/*.twig')
		.pipe($.plumber({
			errorHandler: $.notify.onError({
				title: "Templates task failed",
				message: "<%= error.message %>"
			})
		}))

		.pipe($.data(function () {
			return JSON.parse(fs.readFileSync(_dataPath));
		}))

		.pipe($.twig())

		.pipe(gulp.dest(_paths.tmp))
		.pipe($.if(_paths.current === _paths.tmp, reload({stream: true})));
});


gulp.task('_useref', function () {

	if (_paths.current !== _paths.dist) {
		return;
	}
	var _assets = $.useref.assets();

	return gulp.src(_paths.tmp + '/**/*.html')
		.pipe(_assets)
		.pipe($.debug({title: 'assets'}))
		.pipe($.if('*.css', $.csso()))
		.pipe($.if('*.js', $.uglify()))
		.pipe(_assets.restore())
		.pipe($.useref())

		.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))

		.pipe(gulp.dest(_paths.dist))

		.pipe(reload({stream: true}));
});

gulp.task('_templates', function (callback) {
	runSequence(
		// Compile Twig files
		'_twig',
		// Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets
		'_useref',
		callback
	);
});
<commit_msg>Fix twig dest + useref path vars<commit_after>'use strict';

var fs = require('fs');
var _tempatesSrcPath = _paths.src + '/templates';
var _dataPath = _tempatesSrcPath + '/data.json';


gulp.task('_twig', function () {
	return gulp.src(_tempatesSrcPath + '/**/*.twig')
		.pipe($.plumber({
			errorHandler: $.notify.onError({
				title: "Templates task failed",
				message: "<%= error.message %>"
			})
		}))

		.pipe($.data(function () {
			return JSON.parse(fs.readFileSync(_dataPath));
		}))

		.pipe($.twig())

		.pipe(gulp.dest(_paths.current))
		.pipe($.if(_paths.current === _paths.tmp, reload({stream: true})));
});


gulp.task('_useref', function () {

	if (_paths.current !== _paths.dist) {
		return;
	}
	var _assets = $.useref.assets();

	return gulp.src(_paths.current + '/index.html')
		.pipe(_assets)
		.pipe($.debug({title: 'assets'}))
		.pipe($.if('*.css', $.csso()))
		.pipe($.if('*.js', $.uglify()))
		.pipe(_assets.restore())
		.pipe($.useref())

		.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))

		.pipe(gulp.dest(_paths.dist))

		.pipe(reload({stream: true}));
});

gulp.task('_templates', function (callback) {
	runSequence(
		// Compile Twig files
		'_twig',
		// Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets
		'_useref',
		callback
	);
});

{'fraction_non_alphanumeric': 0.22031963470319635, 'fraction_numerical': 0.0, 'mean_word_length': 3.904850746268657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5084078', 'n_tokens_mistral': 1049, 'n_tokens_neox': 945, 'n_words': 179}