Sha256: 1ac9bb6e3bb675f1ff4d7d358d4195ad88caaa8db124157fe965a995e72eb71f

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

if Enjoy.mongoid?
  module Enjoy::HtmlField
    extend ActiveSupport::Concern

    module ClassMethods
      def enjoy_cms_html_field(name, opts = {})
        clear_by_default = opts.delete(:clear_by_default)
        clear_by_default = false unless clear_by_default == true
        
        field "#{name}_html", opts
        field "#{name}_clear", type: Boolean, default: clear_by_default

        class_eval <<-EVAL
          def #{name}
            self.#{name}_html ||= ""
            return self.#{name}_html unless self.#{name}_clear
            Rails::Html::FullSanitizer.new.sanitize(self.#{name}_html.strip)
          end
        EVAL
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enjoy_cms-0.3.0.4 app/models/concerns/enjoy/html_field.rb
enjoy_cms-0.3.0.3 app/models/concerns/enjoy/html_field.rb
enjoy_cms-0.3.0.2 app/models/concerns/enjoy/html_field.rb