<commit_before>/*jslint nomen: false, sloppy: false */

var fs = require('fs');
var path = require('path');
var Parser = require('./parser.js');
var parser = new Parser();

module.exports = function (config) {
    config = config || {
        root: __dirname,
        layout: null
    };

    return {
        render: function(view, model, body, sections, depth) {
            if (!view) {
                throw new Error("You must specify the view to be rendered.");
            }

            depth = depth || 0;
            if (depth > 50) {
                // Seriously, if you're doing a template system that is 50 layouts deep you're doing something wrong...
                throw new Error('More than 50 layers of layouts.  Make sure the parent layout has "@{ layout = null; }" at the beginning of the file.')
            }

            if ('string' === typeof view) {
                return this.renderFromFile(view, model, body, sections, depth)
            }

            throw new Error("I've not implemented another path for views.  Please specify a file name for the view as a string.");
        },

        renderFromFile: function(fileName, model, body, sections, depth) {
            if (!fileName) {
                throw new Error("You must specify the file name to be rendered.");
            }

            var checkedFiles = [];
            if (!fs.existsSync(fileName)) {
                checkedFiles.push(fileName);

                fileName = config.root + (fileName[0] == path.sep ? '' : path.sep) + fileName;
                fileName = fileName.replace(/\\/g, '\\\\');
                if (!fs.existsSync(fileName)) {
                    checkedFiles.push(fileName);

                    throw new Error("No such view found.  Searched paths: \n" + checkedFiles.join('\n'));
                }
            }

            return this.renderFromString(fs.readFileSync(fileName).toString(), model, body, sections, depth);
        },

        renderFromString: function(contents, model, body, sections, depth) {
            var funcResult = this.parse(contents);
            var result = funcResult.razor.render(model, body, sections);

            if (result.layout) {<commit_msg>Removing a possible issue for windows machines.<commit_after>/*jslint nomen: false, sloppy: false */

var fs = require('fs');
var path = require('path');
var Parser = require('./parser.js');
var parser = new Parser();

module.exports = function (config) {
    config = config || {
        root: __dirname,
        layout: null
    };

    return {
        render: function(view, model, body, sections, depth) {
            if (!view) {
                throw new Error("You must specify the view to be rendered.");
            }

            depth = depth || 0;
            if (depth > 50) {
                // Seriously, if you're doing a template system that is 50 layouts deep you're doing something wrong...
                throw new Error('More than 50 layers of layouts.  Make sure the parent layout has "@{ layout = null; }" at the beginning of the file.')
            }

            if ('string' === typeof view) {
                return this.renderFromFile(view, model, body, sections, depth)
            }

            throw new Error("I've not implemented another path for views.  Please specify a file name for the view as a string.");
        },

        renderFromFile: function(fileName, model, body, sections, depth) {
            if (!fileName) {
                throw new Error("You must specify the file name to be rendered.");
            }

            var checkedFiles = [];
            if (!fs.existsSync(fileName)) {
                checkedFiles.push(fileName);

                fileName = config.root + (fileName[0] == path.sep ? '' : path.sep) + fileName;
                if (!fs.existsSync(fileName)) {
                    checkedFiles.push(fileName);

                    throw new Error("No such view found.  Searched paths: \n" + checkedFiles.join('\n'));
                }
            }

            return this.renderFromString(fs.readFileSync(fileName).toString(), model, body, sections, depth);
        },

        renderFromString: function(contents, model, body, sections, depth) {
            var funcResult = this.parse(contents);
            var result = funcResult.razor.render(model, body, sections);

            if (result.layout) {
{'fraction_non_alphanumeric': 0.11591220850480109, 'fraction_numerical': 0.003657978966620942, 'mean_word_length': 1.876397107166338, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1112448', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1090, 'n_words': 378}