Class: Frontman::Context
Instance Method Summary
collapse
included, #method_missing, #respond_to_missing?
Instance Method Details
#content_for(key, content = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/frontman/context.rb', line 40
def content_for(key, content = nil)
save_buffer
content ||= ''
if block_given?
yield
content = load_buffer
end
restore_buffer
current_page = Frontman::App.instance.current_page
current_page.content_blocks[key.to_sym] = content unless current_page.nil?
end
|
#content_for?(key) ⇒ Boolean
66
67
68
|
# File 'lib/frontman/context.rb', line 66
def content_for?(key)
Frontman::App.instance.current_page.content_blocks.key?(key.to_sym)
end
|
#get_binding(&content) ⇒ Object
80
81
82
|
# File 'lib/frontman/context.rb', line 80
def get_binding(&content)
binding { content }
end
|
#wrap_layout(layout) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/frontman/context.rb', line 15
def wrap_layout(layout)
layout_dir = Frontman::Config.get(:layout_dir, fallback: 'views/layouts')
layout_path = File.join(layout_dir, layout)
save_buffer
yield
content = load_buffer
restore_buffer
Resource.from_path(layout_path, nil, false).render(content)
end
|
#yield_content(key, *_args) ⇒ Object
73
74
75
|
# File 'lib/frontman/context.rb', line 73
def yield_content(key, *_args)
Frontman::App.instance.current_page.content_blocks[key.to_sym]
end
|