<commit_before>'use strict'

module.exports = (
    engine, 
    options= {}
) => {
    if(!engine) new Error(`Engine can't be null`);

    return (ctx, next) => {
        if(ctx.render) return next();

        ctx.render = (relPath, locals = {}) => {
            let state = Object.assign(locals, options, ctx.state || {});
            return engine(relPath, state)
                .then((html) => {
                    ctx.body = html;
                });
        }

        return next();
    };
}<commit_msg>update render.js<commit_after>'use strict'

module.exports = (
  engine,
  options = {}
) => {
  if (!engine) new Error(`Engine can't be null`);

  return (ctx, next) => {
    if (ctx.render || ctx.response.render) return next();

    ctx.render = ctx.response.render = async (relPath, locals = {}) => {
      let state = Object.assign({}, locals, options, ctx.state);
      let html = await engine(relPath, state);

      ctx.body = html;
    }

    return next();
  };
}
{'fraction_non_alphanumeric': 0.1676829268292683, 'fraction_numerical': 0.0, 'mean_word_length': 2.09748427672956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4086258', 'n_tokens_mistral': 309, 'n_tokens_neox': 298, 'n_words': 74}