Skip to content

Commit b322a69

Browse files
committed
expose view context to matestack components and pages
1 parent f38db35 commit b322a69

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

app/concepts/matestack/ui/core/component/dynamic.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Dynamic < Trailblazer::Cell
44
include ::Cell::Haml
55
include Matestack::Ui::Core::ApplicationHelper
66
include Matestack::Ui::Core::ToCell
7+
include Matestack::Ui::Core::HasViewContext
78

89
view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
910
view_paths << "#{::Rails.root}/app/matestack"

app/concepts/matestack/ui/core/page/page.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Page < Trailblazer::Cell
55
include ::Cell::Haml
66
include Matestack::Ui::Core::ApplicationHelper
77
include Matestack::Ui::Core::ToCell
8+
include Matestack::Ui::Core::HasViewContext
89

910
view_paths << "#{Matestack::Ui::Core::Engine.root}/app/concepts"
1011

app/helpers/matestack/ui/core/application_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module ApplicationHelper
66
def render_page(page_class, only_page=false)
77
page_class.new(nil, context: {
88
params: params,
9-
request: request
9+
request: request,
10+
view_context: view_context
1011
}, controller_instance: self).call(:show, nil, only_page)
1112
end
1213

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Matestack::Ui::Core::HasViewContext
2+
def initialize(model = nil, options = {})
3+
@view_context = options[:context][:view_context]
4+
super
5+
end
6+
7+
def method_missing(*args, &block)
8+
@view_context.send(*args, &block)
9+
end
10+
end

0 commit comments

Comments
 (0)