<commit_before>'use strict';

var fs = require('fs');
var hogan = require('hogan.js');
var viewDir;

function compileTemplate(name, fn){
    var fullPath = name,
        tmpl;

    fs.readFile(fullPath, 'utf8', function(err, str){
        if (err) {
            return fn(err);
        }
        try {
            tmpl = hogan.compile(str);
        } catch (e) {
            fn(e);
        }
        fn(null, tmpl);
    });
}

function renderTemplate(name, data, fn){
    compileTemplate(name, function(err, tmpl){
        var result;

        if(err) {
            return fn(err);
        }

        try {
            result = tmpl.render(data);
        } catch (e) {
            err = e;
        }

        fn(err, result);
    });
}

module.exports = renderTemplate;
module.exports.configure = function(app){
    viewDir = app.set('views');
};<commit_msg>Cleanup and fix for unreturned callbacks.<commit_after>'use strict';

var fs = require('fs');
var hogan = require('hogan.js');
var viewDir;

function compileTemplate(fullPath, callback) {
  fs.readFile(fullPath, 'utf8', function (err, str) {
    if (err) {
      return callback(err);
    }

    var template;

    try {
      template = hogan.compile(str);
    } catch (e) {
      return callback(e);
    }

    callback(null, template);
  });
}

function renderTemplate(name, data, callback) {
  compileTemplate(name, function (err, template) {
    if (err) {
      return callback(err);
    }

    var result;

    try {
      result = template.render(data);
    } catch (e) {
      return callback(e);
    }

    callback(null, result);
  });
}

module.exports = renderTemplate;

module.exports.configure = function (app) {
  viewDir = app.set('views');
};
{'fraction_non_alphanumeric': 0.14435389988358557, 'fraction_numerical': 0.0011641443538998836, 'mean_word_length': 2.2556818181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5172503', 'n_tokens_mistral': 557, 'n_tokens_neox': 546, 'n_words': 128}