Class: WWW_App::Clean

Inherits:
Object
  • Object
show all
Defined in:
lib/www_app/TO.rb

Constant Summary collapse

MUSTACHE_Regex =
/\A[a-z0-9\_\.]+\z/i
PERIOD =
'.'.freeze

Class Method Summary collapse

Class Method Details

.method_missing(name, *args) ⇒ Object



117
118
119
# File 'lib/www_app/TO.rb', line 117

def method_missing name, *args
  ::Escape_Escape_Escape.send(name, *args)
end

.mustache(*args) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/www_app/TO.rb', line 96

def mustache *args
  case args.size
  when 2
    meth, val = args
    escape_it = false
  when 3
    escape_it, meth, val = args
  else
    fail ::ArgumentError, "Unknown args: #{args}"
  end

  v = meth.to_s + PERIOD + val.to_s
  fail "Unknown chars: #{args.inspect}" unless v[MUSTACHE_Regex]

  if escape_it
    "!{ #{v} }!"
  else
    "{{{ #{v} }}}"
  end
end