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)
metadata = options
end
if url = options[:url]
if url.start_with?('http')
result = grab_remote(url, options[:css], options)
metadata = options
html = result.to_html
else
html = partial(relative_dir(current_page.path, url).to_s)
end
end
if metadata
options.reverse_merge!(metadata.symbolize_keys!)
end
options[:html] = html
options[:id] = id
models = {}
models[id] = {
iframe: options[:iframe] || false,
stylesheet: options[:stylesheet] || nil,
html: html
}
current_resource.add_metadata({ models: models })
partial('glyptotheque/model', locals: options)
end
|