37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/nanoc/core/executor.rb', line 37
def layout(layout_identifier, = nil)
layout = find_layout(layout_identifier)
filter_name_and_args = @compilation_context.filter_name_and_args_for_layout(layout)
filter_name = filter_name_and_args.name
if filter_name.nil?
raise Nanoc::Core::Errors::CannotDetermineFilter.new(layout_identifier)
end
filter_args = filter_name_and_args.args
filter_args = filter_args.merge( || {})
filter_args.freeze
last = @compilation_context.compiled_content_repo.get_current(@rep)
raise Nanoc::Core::Errors::CannotLayoutBinaryItem.new(@rep) if last.binary?
klass = Nanoc::Core::Filter.named!(filter_name)
layout_view = Nanoc::Core::LayoutView.new(layout, view_context)
filter = klass.new(assigns.merge(layout: layout_view))
@dependency_tracker.bounce(layout, raw_content: true)
begin
Nanoc::Core::NotificationCenter.post(:filtering_started, @rep, filter_name)
content = layout.content
arg = content.binary? ? content.filename : content.string
res = filter.setup_and_run(arg, filter_args)
last = Nanoc::Core::TextualContent.new(res).tap(&:freeze)
@compilation_context.compiled_content_repo.set_current(@rep, last)
ensure
Nanoc::Core::NotificationCenter.post(:filtering_ended, @rep, filter_name)
end
end
|