Sha256: caf61f4af338a959218e5ed3439db565ac3a7573d63bf0905731a028ad7d35b2
Contents?: true
Size: 786 Bytes
Versions: 10
Compression:
Stored size: 786 Bytes
Contents
module Cell::ViewModel::Escaped def self.included(includer) includer.extend Property end module Property def property(*names) super.tap do # super defines #title mod = Module.new do names.each do |name| define_method(name) do |options={}| value = super() # call the original #title. return value unless value.is_a?(String) return value if options[:escape] == false escape!(value) end end end include mod end end end # Property # Can be used as a helper in the cell, too. # Feel free to override and use a different escaping implementation. require "erb" def escape!(string) ::ERB::Util.html_escape(string) end end
Version data entries
10 entries across 10 versions & 1 rubygems