[Haml] Use extend self for Haml::Shared.

This commit is contained in:
Nathan Weizenbaum 2009-04-30 12:52:45 -07:00
parent cc98a81c41
commit 60f9b4f37b
1 changed files with 5 additions and 3 deletions

View File

@ -4,13 +4,15 @@ require 'strscan'
module Haml module Haml
# This module contains functionality that's shared across Haml and Sass. # This module contains functionality that's shared across Haml and Sass.
module Shared module Shared
def self.handle_interpolation(str) extend self
def handle_interpolation(str)
scan = StringScanner.new(str) scan = StringScanner.new(str)
yield scan while scan.scan(/(.*?)(\\*)\#\{/) yield scan while scan.scan(/(.*?)(\\*)\#\{/)
scan.rest scan.rest
end end
def self.balance(scanner, start, finish, count = 0) def balance(scanner, start, finish, count = 0)
str = '' str = ''
scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE) regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
@ -22,7 +24,7 @@ module Haml
end end
end end
def self.human_indentation(indentation, was = false) def human_indentation(indentation, was = false)
if !indentation.include?(?\t) if !indentation.include?(?\t)
noun = 'space' noun = 'space'
elsif !indentation.include?(?\s) elsif !indentation.include?(?\s)