Module: Enjoy::Pages::Models::Block
- Extended by:
- ActiveSupport::Concern
- Includes:
- Enableable, Model, ManualSlug
- Included in:
- Block
- Defined in:
- lib/enjoy/pages/models/block.rb
Instance Method Summary collapse
- #file_fullpath(with_ext = false, ext = ".html.slim") ⇒ Object
- #file_pathname_as_partial ⇒ Object
- #file_pathname_for_fs ⇒ Object
- #nav_options ⇒ Object
- #nav_options_additions ⇒ Object
- #nav_options_default ⇒ Object
- #render_or_content(view, opts = {}) ⇒ Object
- #render_or_content_html(view, opts = {}) ⇒ Object
- #wrapper_attributes=(val) ⇒ Object
Instance Method Details
#file_fullpath(with_ext = false, ext = ".html.slim") ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/enjoy/pages/models/block.rb', line 65 def file_fullpath(with_ext = false, ext = ".html.slim") ret = nil unless self.file_path.blank? res_filename = self.file_pathname_for_fs.to_s res_filename += ext if with_ext ret = Rails.root.join("views", res_filename) end return ret end |
#file_pathname_as_partial ⇒ Object
26 27 28 |
# File 'lib/enjoy/pages/models/block.rb', line 26 def file_pathname_as_partial self.file_pathname.dirname.join("_#{self.file_pathname.basename}") end |
#file_pathname_for_fs ⇒ Object
30 31 32 |
# File 'lib/enjoy/pages/models/block.rb', line 30 def file_pathname_for_fs self.partial ? self.file_path_as_partial : self.file_pathname end |
#nav_options ⇒ Object
75 76 77 |
# File 'lib/enjoy/pages/models/block.rb', line 75 def .deep_merge() end |
#nav_options_additions ⇒ Object
91 92 93 |
# File 'lib/enjoy/pages/models/block.rb', line 91 def {} end |
#nav_options_default ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/enjoy/pages/models/block.rb', line 79 def { highlights_on: false, link_html: { data: { pageblock_selector: self.pageblock_selector, history_name: self.name } } } end |
#render_or_content(view, opts = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/enjoy/pages/models/block.rb', line 53 def render_or_content(view, opts = {}) ret = "" unless self.file_path.blank? opts.merge!(partial: self.file_path) ret = view.render(opts) rescue self.content else ret = self.content end ret = yield ret if block_given? return ret end |
#render_or_content_html(view, opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/enjoy/pages/models/block.rb', line 34 def render_or_content_html(view, opts = {}) ret = "" unless self.file_path.blank? opts.merge!(partial: self.file_path) ret = view.render(opts) rescue self.content_html.html_safe else ret = self.content_html.html_safe end if use_wrapper _attrs = { class: wrapper_class, id: wrapper_id }.merge(wrapper_attributes) ret = view.content_tag wrapper_tag, ret, _attrs end ret = yield ret if block_given? return ret end |
#wrapper_attributes=(val) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/enjoy/pages/models/block.rb', line 95 def wrapper_attributes=(val) if val.is_a? (String) begin begin self[:wrapper_attributes] = JSON.parse(val) rescue self[:wrapper_attributes] = YAML.load(val) end rescue end elsif val.is_a?(Hash) self[:wrapper_attributes] = val else self[:wrapper_attributes] = wrapper_attributes end end |