Module: Cmsable::CmsableHelper
- Defined in:
- app/helpers/cmsable/cmsable_helper.rb
Overview
Cmsable view helpers
Constant Summary collapse
- TYPES =
[ :rich, # CKEditor (default) :plain # Nothing fancy ]
- DEFAULTS =
{ readonly: false, # Can edit by default type: :rich, # Use rich text editor by default plantext: false, # No text editor tag: nil # What tag to use for contenteditable }
Instance Method Summary collapse
Instance Method Details
#cms(name_or_model, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/cmsable/cmsable_helper.rb', line 22 def cms(name_or_model, = {}) model = get_model name_or_model = DEFAULTS.merge # Fail on unknow types type_fail [:type] unless TYPES.include? [:type] # Skip checking permission if set to readonly or # explicit authorisation is passed readonly = .include?(:authorised) || [:readonly] [:authorised] = (model) unless readonly content = model.send(model.cmsable_body).html_safe editable = [:authorised] && ![:readonly] editable ? show_cmsable(content, model, ) : uncmsable(content, [:tag]) end |
#cmsable_assets ⇒ Object
5 6 7 8 |
# File 'app/helpers/cmsable/cmsable_helper.rb', line 5 def cmsable_assets javascript_include_tag('cmsable/application') + stylesheet_link_tag('cmsable/application') end |