<commit_before>/**
 * Module dependencies.
 */
var razor = require('razor');
var path = require('path');

/**
 * Add a render() method to koa that allows
 * you to render almost any templating engine.
 *
 * Example:
 *
 *   app.use(views('./example', {
 *     html: 'underscore'
 *   }));
 *
 *   // in your route handler
 *   this.body = yield this.render('index');
 *
 * @param {String} path
 * @param {String} ext (optional)
 * @param {Object} opts (optional)
 * @return {Function} middleware
 * @api public
 */

module.exports = function (dir) {
  console.log('add render() method to `this.ctx`');

  // get render function
  

  // middleware
  return function *views(next) {
    renderFn = render(dir);
    this.render = renderFn;
    yield next;
    }
}

/**
 * Determine `render()` function.
 * 
 * @param {String} path
 * @return {Generator} view
 * @api private
 */

function render ( dir) {
    
    return function (view,  model){
       
   var file = path.join(dir, view) + ".js.html";
   
     return function(callback){
         var ctx=this;
         razor.findView(file, function(template){
             if (template == undefined)
             {
                 var err = new Error("Not Found");
                 err.status = 404;
                 err.expose = true;
                callback(err, null);<commit_msg>removed logging<commit_after>/**
 * Module dependencies.
 */
var razor = require('razor');
var path = require('path');

/**
 * Add a render() method to koa that allows
 * you to render almost any templating engine.
 *
 * Example:
 *
 *   app.use(views('./example', {
 *     html: 'underscore'
 *   }));
 *
 *   // in your route handler
 *   this.body = yield this.render('index');
 *
 * @param {String} path
 * @param {String} ext (optional)
 * @param {Object} opts (optional)
 * @return {Function} middleware
 * @api public
 */

module.exports = function (dir) {
 
  // middleware
  return function *views(next) {
    renderFn = render(dir);
    this.render = renderFn;
    yield next;
    }
}

/**
 * Determine `render()` function.
 * 
 * @param {String} path
 * @return {Generator} view
 * @api private
 */

function render ( dir) {
    
    return function (view,  model){
       
   var file = path.join(dir, view) + ".js.html";
   
     return function(callback){
         var ctx=this;
         razor.findView(file, function(template){
             if (template == undefined)
             {
                 var err = new Error("Not Found");
                 err.status = 404;
                 err.expose = true;
                callback(err, null);
{'fraction_non_alphanumeric': 0.1471042471042471, 'fraction_numerical': 0.0023166023166023165, 'mean_word_length': 2.23875, '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': '429472', 'n_tokens_mistral': 793, 'n_tokens_neox': 775, 'n_words': 222}