Module: InlineHelper

Defined in:
app/helpers/inline_helper.rb

Instance Method Summary collapse

Instance Method Details

#inline(record, field_name, options = {}) ⇒ Object Also known as: model_phrase



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/inline_helper.rb', line 18

def inline(record, field_name, options={})
  return record.send(field_name).to_s.html_safe unless can_edit_phrases?

  klass = 'phrasable'
  klass += ' phrasable_on' if edit_mode_on?
  klass += ' inverse' if options[:inverse]
  klass += options[:class] if options[:class]

  url = phrasing_polymorphic_url(record, field_name)

  (:span, { class: klass, contenteditable: edit_mode_on?, spellcheck: false,   "data-url" => url}) do 
    (record.send(field_name) || record.try(:key)).to_s.html_safe
  end
end

#phrase(*args) ⇒ Object

Data model phrase phrase(@record, :title, inverse: true, class: phrase-record-title)



8
9
10
11
12
13
14
15
16
# File 'app/helpers/inline_helper.rb', line 8

def phrase(*args)
  if args[0].class == String or args[0].class == Symbol
    key, options = args[0].to_s, args[1]
    phrasing_phrase(key,options)
  else
    record, field_name, options = args[0], args[1], args[2]
    inline(record, field_name, options || {})
  end
end