<commit_before>module Nesta
  module Overrides
    module Renderers
      def haml(template, options = {}, locals = {})
        render_options = Nesta::Overrides.render_options(template, :haml)
        super(template, render_options.merge(options), locals)
      end

      def scss(template, options = {}, locals = {})
        render_options = Nesta::Overrides.render_options(template, :scss)
        super(template, render_options.merge(options), locals)
      end

      def sass(template, options = {}, locals = {})
        render_options = Nesta::Overrides.render_options(template, :sass)
        super(template, render_options.merge(options), locals)
      end
    end

    def self.load_local_app
      require Nesta::Path.local("app")
    rescue LoadError
    end
    
    def self.local_view_path
      Nesta::Path.local("views")
    end
    
    def self.load_theme_app
      if Nesta::Config.theme
        require Nesta::Path.themes(Nesta::Config.theme, "app")
      end
    rescue LoadError
    end

    def self.theme_view_path
      if Nesta::Config.theme.nil?
        nil
      else
        File.join(Nesta::Path.themes, Nesta::Config.theme, "views")
      end
    end

    def self.template_exists?(engine, views, template)
      views && File.exist?(File.join(views, "#{template}.#{engine}"))
    end

    def self.render_options(template, engine)
      if template_exists?(engine, local_view_path, template)
        { :views => local_view_path }
      elsif template_exists?(engine, theme_view_path, template)
        { :views => theme_view_path }
      else
        {}
      end
    end
  end
end<commit_msg>Improved clarity of rendering methods.<commit_after>module Nesta
  module Overrides
    module Renderers
      def haml(template, options = {}, locals = {})
        defaults = Nesta::Overrides.render_options(template, :haml)
        super(template, defaults.merge(options), locals)
      end

      def scss(template, options = {}, locals = {})
        defaults = Nesta::Overrides.render_options(template, :scss)
        super(template, defaults.merge(options), locals)
      end

      def sass(template, options = {}, locals = {})
        defaults = Nesta::Overrides.render_options(template, :sass)
        super(template, defaults.merge(options), locals)
      end
    end

    def self.load_local_app
      require Nesta::Path.local("app")
    rescue LoadError
    end
    
    def self.load_theme_app
      if Nesta::Config.theme
        require Nesta::Path.themes(Nesta::Config.theme, "app")
      end
    rescue LoadError
    end

    private
      def self.template_exists?(engine, views, template)
        views && File.exist?(File.join(views, "#{template}.#{engine}"))
      end

      def self.render_options(template, engine)
        if template_exists?(engine, local_view_path, template)
          { :views => local_view_path }
        elsif template_exists?(engine, theme_view_path, template)
          { :views => theme_view_path }
        else
          {}
        end
      end

      def self.local_view_path
        Nesta::Path.local("views")
      end
    
      def self.theme_view_path
        if Nesta::Config.theme.nil?
          nil
        else
          Nesta::Path.themes(Nesta::Config.theme, "views")
        end
      end
  end
end
{'fraction_non_alphanumeric': 0.10857664233576643, 'fraction_numerical': 0.0, 'mean_word_length': 2.5556756756756758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '572259', 'n_tokens_mistral': 976, 'n_tokens_neox': 988, 'n_words': 205}