Module: Card::Set::All::RichHtml::ProcessLayout::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod021-standard/all/rich_html/process_layout.rb

Instance Method Summary collapse

Instance Method Details

#explicit_modal_wrapper?(view) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
64
65
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 61

def explicit_modal_wrapper? view
  return unless view_setting(:wrap, view)

  wrapper_names(view_setting(:wrap, view)).any? { |n| n == :modal || n == :bridge }
end

#layout_name_from_ruleObject



75
76
77
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 75

def layout_name_from_rule
  card.rule_card(:layout)&.try :item_name
end

#main_render_args(view, args) ⇒ Object



24
25
26
27
28
29
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 24

def main_render_args view, args
  args[:view] = view if view
  args[:main] = true
  args[:main_view] = true
  args
end

#page_layoutObject



31
32
33
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 31

def page_layout
  params[:layout] || layout_name_from_rule || :default
end

#render_outside_of_layout(view, args) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 43

def render_outside_of_layout view, args
  body = render_with_layout(nil, page_layout, {})
  modal = render!(view, args)
  if body.include?("</body>")
    # a bit hacky
    # the problem is that the body tag has to be in the layout
    # so that you can add layout css classes like <body class="right-sidebar">
    body.sub!("</body>", "#{modal}</body>")
  else
    body += modal
  end
  body
end

#render_with_layout(view, layout, args = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 35

def render_with_layout view, layout, args={}
  view_opts = Layout.main_nest_opts(layout, self)
  view ||= view_opts.delete(:view) || default_nest_view
  view_opts[:home_view] = view
  view_opts[:layout] = layout
  render! view, view_opts.reverse_merge(args)
end

#show_layout?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 57

def show_layout?
  !Env.ajax? || params[:layout]
end

#show_with_page_layout(view, args) ⇒ Object

TODO: use CodeFile cards for these builtin layouts allow for rescue / testing HTML_LAYOUTS = Mod::Loader.load_layouts(:html).merge "none" => "{_main}" HAML_LAYOUTS = Mod::Loader.load_layouts(:haml)



14
15
16
17
18
19
20
21
22
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 14

def show_with_page_layout view, args
  main!
  args = main_render_args view, args
  if explicit_modal_wrapper?(view) && page_layout.to_sym != :modal
    render_outside_of_layout view, args
  else
    render_with_layout view, page_layout, args
  end
end

#wrapper_names(wrappers) ⇒ Object



67
68
69
70
71
72
73
# File 'tmpsets/set/mod021-standard/all/rich_html/process_layout.rb', line 67

def wrapper_names wrappers
  case wrappers
  when Hash  then wrappers.keys
  when Array then wrappers.map { |w| w.is_a?(Array) ? w.first : w }
  else            [wrappers]
  end
end