Skip to content

Commit 24ec395

Browse files
committedFeb 4, 2014
component: allow a block in #text
1 parent 3242451 commit 24ec395

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed
 

‎opal/lissio/component.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,16 @@ def self.html(string = nil, &block)
127127
end
128128
end
129129

130-
def self.text(string)
131-
render {
132-
element.content = string
133-
}
130+
def self.text(string = nil, &block)
131+
if block
132+
render {
133+
element.content = instance_exec(&block)
134+
}
135+
else
136+
render {
137+
element.content = string
138+
}
139+
end
134140
end
135141

136142
def self.css!(content = nil, &block)

0 commit comments

Comments
 (0)
Please sign in to comment.