Skip to content

Commit

Permalink
reapplied prepare method
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasjabari committed Mar 12, 2021
1 parent ea7b78a commit 5813346
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/matestack/ui/core/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def initialize(html_tag = nil, text = nil, options = {}, &block)
self.escape = self.options.delete(:escape) || true
self.parent = Matestack::Ui::Core::Context.parent
self.parent.children << self if self.parent if self.bind_to_parent
self.prepare
Matestack::Ui::Core::Context.parent = self
# create children
create_children(&block)
Matestack::Ui::Core::Context.parent = self.parent
self
Expand All @@ -40,12 +40,17 @@ def extract_options(text, options)
end
end

def prepare
# can be optionally overwritten in subclass in order to set
# instance vars for example, might get deprecated in the future
end

# create child items by either running the response method if exists or executing the block
# overwrite if needed (like in pages or apps)
def create_children(&block)
if respond_to?(:response)
self.response &block
else
else
block.call if block_given?
end
end
Expand Down Expand Up @@ -94,4 +99,4 @@ def vue
end
end
end
end
end

0 comments on commit 5813346

Please sign in to comment.