Module: Middleman::Sculptor::Helpers::Model

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

Instance Method Summary collapse

Instance Method Details

#imodel(location = nil, options = {}, &block) ⇒ Object



46
47
48
49
# File 'lib/middleman-sculptor/helpers/model.rb', line 46

def imodel(location=nil, options={}, &block)
  options[:iframe] = true
  model(location, options, &block)
end

#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

#model_source(type, &block) ⇒ Object



51
52
53
54
# File 'lib/middleman-sculptor/helpers/model.rb', line 51

def model_source(type, &block)
  source_code = capture_html(&block)
  partial('glyptotheque/model-source', locals: { source_type: type, source_code: source_code })
end