Module: Alchemy::Hints

Included in:
Content, Element, Page
Defined in:
lib/alchemy/hints.rb

Instance Method Summary collapse

Instance Method Details

#has_hint?Boolean

Returns true if the element has a hint

Returns:

  • (Boolean)


46
47
48
# File 'lib/alchemy/hints.rb', line 46

def has_hint?
  hint.present?
end

#hintObject

Returns a hint

To add a hint to a content pass hint: true to the element definition in its element.yml

Then the hint itself is placed in the locale yml files.

Alternativly you can pass the hint itself to the hint key.

Locale Example:

# elements.yml
- name: headline
  contents:
  - name: headline
    type: EssenceText
    hint: true

# config/locales/de.yml
  de:
    content_hints:
      headline: Lorem ipsum

Hint Key Example:

- name: headline
  contents:
  - name: headline
    type: EssenceText
    hint: Lorem ipsum

Returns:

  • String



36
37
38
39
40
41
42
43
# File 'lib/alchemy/hints.rb', line 36

def hint
  hint = definition['hint']
  if hint == true
    I18n.t(name, scope: hint_translation_scope)
  else
    hint
  end
end