class Slim::Mustache::Filter
Handle ~mustache syntax
Public Instance Methods
on_slim_interpolate(string)
click to toggle source
# File lib/slim/mustache/filter.rb, line 14 def on_slim_interpolate(string) matches = string.scan(/([^~]*)~([!>])?(\((.*)\)|([^ ]*[\w}])|\.)([^~]*)/) if matches.any? stack = [:multi] matches.each do |first, prefix, text, clean_text, _, last| prefix = "#{prefix} " if prefix text = clean_text if clean_text stack << [:multi, [:slim, :interpolate, first], [:static, "{{#{prefix}"], [:slim, :interpolate, text], [:static, "}}"], [:slim, :interpolate, last]] end stack else [:slim, :interpolate, string] end end
on_slim_mustache(line, content)
click to toggle source
# File lib/slim/mustache/filter.rb, line 6 def on_slim_mustache(line, content) if match = line.match(/\A~([#\^]([^ ]*).*)/) [:multi, [:static, "{{#{match[1]}}}"], compile(content), [:static, "{{/#{match[2]}}}"]] else on_slim_interpolate(line) end end