module Enjoy::Pages::Models::Block

Public Instance Methods

file_fullpath(with_ext = false, ext = ".html.slim") click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
nav_options_additions() click to toggle source
nav_options_default() click to toggle source
render_or_content(view, opts = {}) { |ret| ... } click to toggle source
# 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 = {}) { |ret| ... } click to toggle source
# 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) click to toggle source
# 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