<commit_before># -*- coding: utf-8 -*-

###
### $Release: 0.0.0 $
### $Copyright: copyright(c) 2014 kuwata-lab.com all rights reserved $
### $License: MIT License $
###


module BabyErubis

  ##
  ## Module to define template rendering methods.
  ##
  ## ex:
  ##   class MyController
  ##     include BabyErubis::HtmlEscaper
  ##     include BabyErubis::Renderer
  ##
  ##     #ERUBY_PATH      = ['.', 'templates']
  ##     #ERUBY_LAYOUT    = :_layout
  ##     #ERUBY_HTML_EXT  = '.html.eruby'
  ##     #ERUBY_TEXT_EXT  = '.eruby'
  ##     #ERUBY_CACHE     = {}
  ##
  ##     def index
  ##       @items = ['A', 'B', 'C']
  ##       ## renders 'templates/welcome.html.eruby'
  ##       html = eruby_render_html(:welcome)
  ##       return html
  ##     end
  ##   end
  ##
  ##
  module Renderer

    ERUBY_PATH      = ['.']
    ERUBY_LAYOUT    = :_layout
    ERUBY_HTML_CLASS = BabyErubis::Html
    ERUBY_HTML_EXT  = '.html.eruby'
    ERUBY_TEXT_CLASS = BabyErubis::Text
    ERUBY_TEXT_EXT  = '.eruby'
    ERUBY_CACHE     = {}

    def eruby_render_html(template_name, layout: true, encoding: 'utf-8')
      return _eruby_render_template(template_name, layout) {|tmpl_name|
        ext = self.class.const_get :ERUBY_HTML_EXT
        _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
          tmpl_class = self.class.const_get :ERUBY_HTML_CLASS
          tmpl_class.new.from_file(fpath, encoding)
        }
      }
    end

    def eruby_render_text(template_name, layout: false, encoding: 'utf-8')
      return _eruby_render_template(template_name, layout) {|tmpl_name|
        ext = self.class.const_get :ERUBY_TEXT_EXT
        _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
          tmpl_class = self.class.const_get :ERUBY_TEXT_CLASS
          tmpl_class.new.from_file(fpath, encoding)
        }
      }
    end

    private
<commit_msg>ruby: tweak spacing<commit_after># -*- coding: utf-8 -*-

###
### $Release: 0.0.0 $
### $Copyright: copyright(c) 2014 kuwata-lab.com all rights reserved $
### $License: MIT License $
###


module BabyErubis

  ##
  ## Module to define template rendering methods.
  ##
  ## ex:
  ##   class MyController
  ##     include BabyErubis::HtmlEscaper
  ##     include BabyErubis::Renderer
  ##
  ##     #ERUBY_PATH      = ['.', 'templates']
  ##     #ERUBY_LAYOUT    = :_layout
  ##     #ERUBY_HTML_EXT  = '.html.eruby'
  ##     #ERUBY_TEXT_EXT  = '.eruby'
  ##     #ERUBY_CACHE     = {}
  ##
  ##     def index
  ##       @items = ['A', 'B', 'C']
  ##       ## renders 'templates/welcome.html.eruby'
  ##       html = eruby_render_html(:welcome)
  ##       return html
  ##     end
  ##   end
  ##
  ##
  module Renderer

    ERUBY_PATH         = ['.']
    ERUBY_LAYOUT       = :_layout
    ERUBY_HTML_CLASS   = BabyErubis::Html
    ERUBY_HTML_EXT     = '.html.eruby'
    ERUBY_TEXT_CLASS   = BabyErubis::Text
    ERUBY_TEXT_EXT     = '.eruby'
    ERUBY_CACHE        = {}

    def eruby_render_html(template_name, layout: true, encoding: 'utf-8')
      return _eruby_render_template(template_name, layout) {|tmpl_name|
        ext = self.class.const_get :ERUBY_HTML_EXT
        _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
          tmpl_class = self.class.const_get :ERUBY_HTML_CLASS
          tmpl_class.new.from_file(fpath, encoding)
        }
      }
    end

    def eruby_render_text(template_name, layout: false, encoding: 'utf-8')
      return _eruby_render_template(template_name, layout) {|tmpl_name|
        ext = self.class.const_get :ERUBY_TEXT_EXT
        _eruby_find_template("#{tmpl_name}#{ext}") {|fpath|
          tmpl_class = self.class.const_get :ERUBY_TEXT_CLASS
          tmpl_class.new.from_file(fpath, encoding)
        }
      }
    end

    private

{'fraction_non_alphanumeric': 0.13818084250067078, 'fraction_numerical': 0.005366246310705662, 'mean_word_length': 2.5572519083969465, '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': '212857', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1393, 'n_words': 222}