<commit_before>/* global config, fs */

module.exports = function(grunt) {
	var glob = require('glob');

	grunt.registerTask('loadViews', function() {
		var data = {};

		// Find core view templates
		var matches = glob.sync(config.paths.viewSource + 'load/**/*.html');

		if (matches.length) {
			matches.forEach(function(view) {
				var key = view.replace(config.paths.viewSource + 'load/', '')
					.replace('/', '.').slice(0, -5);

				data[key] = fs.readFileSync(view, 'utf8')
					.replace(/\s*\n+\t*/g, '');
			});
		}

		// Find module view templates
		config.modules.forEach(function(name) {
			var root = config.paths.moduleSource + name;
			matches = glob.sync(root + '/core/js/views/load/**/*.html');

			if (matches.length) {
				matches.forEach(function(view) {
					var key = name + '.' +
						view.replace(root + '/core/js/views/load/', '')
							.replace('/', '.').slice(0, -5);

					data[key] = fs.readFileSync(view, 'utf8')
						.replace(/\s*\n+\t*/g, '');
				});
			}
		});

		if (Object.keys(data).length) {
			// JSON encode and inject templates
			fs.writeFileSync(
				config.paths.temp + 'views.js',
				'Wee.view.addView(' + JSON.stringify(data) + ');'
			);
		}
	});
};<commit_msg>Resolve and improve view minification logic<commit_after>/* global config, fs */

module.exports = function(grunt) {
	var glob = require('glob');

	grunt.registerTask('loadViews', function() {
		var data = {};

		// Find core view templates
		var matches = glob.sync(config.paths.viewSource + 'load/**/*.html');

		if (matches.length) {
			matches.forEach(function(view) {
				var key = view.replace(config.paths.viewSource + 'load/', '')
					.replace('/', '.').slice(0, -5);

				data[key] = fs.readFileSync(view, 'utf8')
					.replace(/\s*\n+\t*/g, '');
			});
		}

		// Find module view templates
		config.modules.forEach(function(name) {
			var root = config.paths.moduleSource + name;
			matches = glob.sync(root + '/core/js/views/load/**/*.html');

			if (matches.length) {
				matches.forEach(function(view) {
					var key = name + '.' +
						view.replace(root + '/core/js/views/load/', '')
							.replace('/', '.').slice(0, -5);

					data[key] = fs.readFileSync(view, 'utf8')
						.replace(/[\s][\s]*/g, ' ')
						.replace(/[\s]*>[\s]*/g, '>')
						.replace(/[\s]*<[\s]*/g, '<');
				});
			}
		});

		if (Object.keys(data).length) {
			// JSON encode and inject templates
			fs.writeFileSync(
				config.paths.temp + 'views.js',
				'Wee.view.addView(' + JSON.stringify(data) + ');'
			);
		}
	});
};
{'fraction_non_alphanumeric': 0.22182680901542112, 'fraction_numerical': 0.004744958481613286, 'mean_word_length': 2.7761194029850746, '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': '3723412', 'n_tokens_mistral': 1072, 'n_tokens_neox': 890, 'n_words': 155}