Method: Middleman::Sculptor::Helpers::Model#model

Defined in:
lib/middleman-sculptor/helpers/model.rb

#model(*options, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/middleman-sculptor/helpers/model.rb', line 7

def model(*options, &block)
  id = options.first.is_a?(String) && options.shift || nil
  options = options.first || {}
  if block_given?
    html = capture_html(&block)
     = options
  end

  if url = options[:url]
    # Remote URL
    if url.start_with?('http')
      result = grab_remote(url, options[:css], options)
       = options
      html = result.to_html
    # Assume local path
    else
      html = partial(relative_dir(current_page.path, url).to_s)
    end
  end

  if 
    options.reverse_merge!(.symbolize_keys!)
  end

  options[:html] = html
  options[:id] = id

  models = {}
  models[id] = {
    iframe: options[:iframe] || false,
    stylesheet: options[:stylesheet] || nil,
    html: html
  }

  current_resource.({ models: models })

  partial('glyptotheque/model', locals: options)
end