<commit_before>import path from 'path';
import _ from 'lodash';
import minimatch from "minimatch";

let allFiles = {}

module.exports.helpers = {
	equal(lvalue, rvalue, options) {
		if (arguments.length < 3)
			throw new Error("Handlebars Helper equal needs 2 parameters");
		if( lvalue!=rvalue ) {
			return options.inverse(this);
		} else {
			return options.fn(this);
		}
	},

 eachFile() {
		let args = Array.slice(arguments);
		let options = _.last(args)
		let globs = args.slice(0, args.length-1);

		let result = "";

		_.each(allFiles, (f,p) => {
			let matches = _.any(globs, g => minimatch(p,g));
			if (!matches) return

			result += options.fn({path: p, file: f});
		});

		return result;
	},

	sidebarSubMenu(title, options) {
		return `
			<li class="pageNavList__subList">
				<span class="pageNavList__title">${title}</span>
				<ul>	
					${options.fn(this)}	
				</ul>
			</li>
		`;
	},
}


module.exports.setFileList = function(files) {<commit_msg>Fix context loss for eachFile helper<commit_after>import path from 'path';
import _ from 'lodash';
import minimatch from "minimatch";

let allFiles = {}

module.exports.helpers = {
	equal(lvalue, rvalue, options) {
		if (arguments.length < 3)
			throw new Error("Handlebars Helper equal needs 2 parameters");
		if( lvalue!=rvalue ) {
			return options.inverse(this);
		} else {
			return options.fn(this);
		}
	},

 eachFile() {
		let args = Array.slice(arguments);
		let options = _.last(args)
		let globs = args.slice(0, args.length-1);

		let result = "";

		_.each(allFiles, (f,p) => {
			let matches = _.any(globs, g => minimatch(p,g));
			if (!matches) return

			let ctx = _.extend({}, this, {path: p, file: f})

			result += options.fn(ctx);
		});

		return result;
	},

	sidebarSubMenu(title, options) {
		return `
			<li class="pageNavList__subList">
				<span class="pageNavList__title">${title}</span>
				<ul>	
					${options.fn(this)}	
				</ul>
			</li>
		`;
	},
}


module.exports.setFileList = function(files) {
{'fraction_non_alphanumeric': 0.16541353383458646, 'fraction_numerical': 0.0040100250626566416, 'mean_word_length': 3.4853932584269662, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '2803055', 'n_tokens_mistral': 810, 'n_tokens_neox': 702, 'n_words': 166}