Sha256: 76c1c037a02435bc64d04a6e369560b11c89452a2888028b86d518d7e3b66d44
Contents?: true
Size: 669 Bytes
Versions: 12
Compression:
Stored size: 669 Bytes
Contents
require "coderay" event :validate_json, :validate, on: :save, changed: :content do check_json_syntax if content.present? end def check_json_syntax parse_content rescue JSON::ParserError => e errors.add t(:format_invalid_json), e.message.sub(/^\d+: /, "").to_s end def parse_content content.blank? ? "" : JSON.parse(content) end def item_names _args={} parse_content.keys.map(&:to_name) end def item_values parse_content.values end def item_value name parse_content[name] end format :html do view :core do process_content ::CodeRay.scan(_render_raw, :json).div end def input_type :ace_editor end def ace_mode :json end end
Version data entries
12 entries across 12 versions & 1 rubygems