To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorCustom Builders
- Scenarios
-
- Defining a custom builder
-
- Given
-
a file named "custom_builder.rb" with:
require "html/builder" require "html/tag" require "html/list" module HTML class Footer < Struct.new(:owner, :year) def copyright "© #{year} #{owner}" end def to_html Tag.new(:p, copyright).to_html end end end output = HTML::Builder.build do list(:p, [1, 2]) + footer("Foo, Inc.", 2012) end print output
- When
-
I run
ruby custom_builder.rb
- Then
-
the output should contain exactly:
<p>1</p><p>2</p><p>© 2012 Foo, Inc.</p>
Last published almost 7 years ago by samwgoldman.