Skip to content

Commit a72fc5b

Browse files
committed
start using blocks
1 parent ca0007a commit a72fc5b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lib/baseballbot/templates/sidebar.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ class Sidebar < Template
66
include Sidebars::Components
77

88
def inspect = %(#<#{self.class.name} @subreddit="#{@subreddit.name}">)
9+
10+
def evaluated_body
11+
return super unless @blocks && !@blocks.empty?
12+
13+
@blocks
14+
.map { block_for(it) }
15+
.join("\n\n")
16+
end
17+
18+
def block_for(block)
19+
case block['type']
20+
when 'division_standings'
21+
Blocks::DivisionStandings.new(subreddit, template: self, **block).render
22+
when 'calendar'
23+
Blocks::Calendar.new(subreddit, template: self, **block).render
24+
else
25+
block['content']
26+
end
27+
end
928
end
1029
end
1130
end

0 commit comments

Comments
 (0)