<commit_before>module ThirdRail::Handlebars
  class Binding
    attr_reader :__args

    def initialize(**args)
      @__args = args

      # set up our Tilt output buffer
      instance_variable_set(__args[:outvar], "")
    end

    # `method_missing` should only handle two things:
    #  - converting token -> expression (including any arguments passed)
    #  - injecting content for block calls back into the calling context
    #
    # Everything else can (and should) be handled by Expression.
    def method_missing(token, *args, &block)

      # We've been passed a block, so evaluate it in the context of a new binding,
      # thus ensuring we capture it for injection in the proper order of things
      if block_given?
        __buffer << Expression.new(token, *args).to_s { __rebind(block) }

      # special case; has been called in the context of a block with a non-output
      # node; inject it into the current buffer
      elsif token == :else
        __buffer << Expression.new(token, *args)

      # default case: called from an output block, ergo we can just return
      # something that responds to to_str
      else
        Expression.new(token, *args)
      end
    end

    # Return self for any tokens that map to Ruby keywords (if, else, unless)
    def __hb
      self
    end

    # Because Tilt injects a local variable named 'this' into our binding,
    # we need this as a work-around for self-reference bindings
    def _this
      Expression.new(:this)
    end

    # # A special case; because this shouldn't be called as an output, we need to inject
    # # it directly into our output buffer
    # def _else
    #   __buffer << Expression.new(:else)
    # end

    private<commit_msg>clean up commented out methods<commit_after>module ThirdRail::Handlebars
  class Binding
    attr_reader :__args

    def initialize(**args)
      @__args = args

      # set up our Tilt output buffer
      instance_variable_set(__args[:outvar], "")
    end

    # `method_missing` should only handle two things:
    #  - converting token -> expression (including any arguments passed)
    #  - injecting content for block calls back into the calling context
    #
    # Everything else can (and should) be handled by Expression.
    def method_missing(token, *args, &block)

      # We've been passed a block, so evaluate it in the context of a new binding,
      # thus ensuring we capture it for injection in the proper order of things
      if block_given?
        __buffer << Expression.new(token, *args).to_s { __rebind(block) }

      # special case; has been called in the context of a block with a non-output
      # node; inject it into the current buffer
      elsif token == :else
        __buffer << Expression.new(token, *args)

      # default case: called from an output block, ergo we can just return
      # something that responds to to_str
      else
        Expression.new(token, *args)
      end
    end

    # Return self as a proxy for any tokens that map to Ruby keywords (if, else, unless)
    def __hb
      self
    end

    # Because Tilt injects a local variable named 'this' into our binding,
    # we need this as a work-around for self-reference bindings
    def _this
      Expression.new(:this)
    end

    private
{'fraction_non_alphanumeric': 0.06721662083715246, 'fraction_numerical': 0.0, 'mean_word_length': 2.6621923937360177, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5269306', 'n_tokens_mistral': 901, 'n_tokens_neox': 860, 'n_words': 390}