Sha256: b894bcd4a3ec7ac191e4a02dfdb04a042b0310bb375cdcd624a4cc118eeb1daf
Contents?: true
Size: 1.28 KB
Versions: 48
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Alchemy module Hints # Returns a hint # # To add a hint to a ingredient 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 # ingredients: # - role: headline # type: Text # hint: true # # # config/locales/de.yml # de: # ingredient_hints: # headline: Lorem ipsum # # == Hint Key Example: # # - name: headline # ingredients: # - role: headline # type: Text # hint: Lorem ipsum # # @return String # def hint hint = definition[:hint] if hint == true Alchemy.t(hint_translation_attribute, scope: hint_translation_scope) else hint end end # Returns true if the element has a hint defined def has_hint? !!definition[:hint] end private def hint_translation_attribute name end def hint_translation_scope "#{self.class.model_name.to_s.demodulize.downcase}_hints" end end end
Version data entries
48 entries across 48 versions & 1 rubygems