Module: Changeful::ViewHelpers
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::OutputSafetyHelper
- Defined in:
- lib/changeful/helpers/view_helpers.rb
Overview
The Changeful ViewHelpers expose the methods to be used in view to make the static content editable
Instance Method Summary collapse
-
#changeful_content(key, options = {}) ⇒ String
(also: #cc)
Returns a content based on a key and store in the database if it does not exist.
Instance Method Details
#changeful_content(key, options = {}) ⇒ String Also known as: cc
Returns a content based on a key and store in the database if it does not exist
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/changeful/helpers/view_helpers.rb', line 28 def changeful_content(key, = {}) contents ||= Content.all_contents_in(current_view) if contents.present? contents.each do |datum| return raw(datum.content) if datum.key == key.to_s end end content = .delete(:default) || capture(&proc) view_type = .delete(:type) || :plain Content.create!(key: key, content: content, view_type: view_type, file_path: current_view) return content end |