class ExtractI18n::Slimkeyfy::Whitespacer
Constants
- HTML
- HTML_TAGS
Public Class Methods
convert_nbsp(body, tag)
click to toggle source
# File lib/extract_i18n/slimkeyfy/whitespacer.rb, line 25 def self.convert_nbsp(body, tag) lead = leading_nbsp(body) trail = trailing_nsbp(body, tag) tag = tag.gsub(tag, "#{tag}#{lead}#{trail}") [body.sub(/^ /, '').sub(/ $/, '').gsub(" ", " "), tag.gsub("=><", "=<>")] end
convert_slim(string)
click to toggle source
# File lib/extract_i18n/slimkeyfy/whitespacer.rb, line 8 def self.convert_slim(string) m = string.match(HTML_TAGS) return string if m.nil? or m[:html_tag].nil? return string if has_equals_tag?(string, m[:html_tag]) tag = m[:html_tag] case tag when /\|/ string.gsub("|", "=") when /\'/ string.gsub("'", "=>") when HTML string.gsub(string, "#{string} =") else string end end
has_equals_tag?(string, html_tag)
click to toggle source
# File lib/extract_i18n/slimkeyfy/whitespacer.rb, line 42 def self.has_equals_tag?(string, html_tag) string.gsub(html_tag, "").strip.start_with?("=") end
leading_nbsp(body)
click to toggle source
# File lib/extract_i18n/slimkeyfy/whitespacer.rb, line 33 def self.leading_nbsp(body) return "<" if body.start_with?(" ") end
trailing_nsbp(body, tag)
click to toggle source
# File lib/extract_i18n/slimkeyfy/whitespacer.rb, line 37 def self.trailing_nsbp(body, tag) return '' if tag.start_with?("=>") return ">" if body.end_with?(" ") end