<commit_before>require 'rubygems'
require 'frontable'
require 'tilt'

module UsesThis
  class Template
    include Frontable
    attr_accessor :site, :slug, :renderer, :metadata

    def initialize(site, path)
      @site = site
      @renderer = Tilt.new(path)
      @slug = File.basename(path, File.extname(path))

      @metadata, _ = read_with_yaml(path)
    end

    def render(context, params, contents)
      output = @renderer.render(context, params) {
        contents
      }

      if @metadata['layout'] && @site.templates[@metadata['layout']]
        output = @site.templates[@metadata['layout']].render(context, params, contents)
      end

      output
    end
  end
end<commit_msg>Switched to using Erubis directly.<commit_after>require 'rubygems'
require 'frontable'
require 'erubis'

module UsesThis
  class Template
    include Frontable
    attr_accessor :site, :slug, :metadata, :contents

    def initialize(site, path)
      @site = site
      @slug = File.basename(path, File.extname(path))

      @metadata, @contents = read_with_yaml(path)
    end

    def render(params = {}, contents = nil)
      params[:site] = @site

      output = Erubis::Eruby.new(@contents).result(params, &(contents ? lambda { contents } : nil))

      if @metadata['layout'] && @site.templates[@metadata['layout']]
        output = @site.templates[@metadata['layout']].render(params, output)
      end

      output
    end
  end
end
{'fraction_non_alphanumeric': 0.12534818941504178, 'fraction_numerical': 0.0, 'mean_word_length': 3.2389380530973453, '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': '738433', 'n_tokens_mistral': 443, 'n_tokens_neox': 438, 'n_words': 105}