Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New exercise

  • Loading branch information...
commit 7a9a236a82321501713cd9216065882d54fc5744 1 parent e8c303b
@citizen428 authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 exercise_9_tag_builder/tag_builder.markdown
View
20 exercise_9_tag_builder/tag_builder.markdown
@@ -0,0 +1,20 @@
+In this exercise I want you to write a little DSL for XML/HTML. Look at the following client code:
+
+ title = tag_builder("h1")
+ para = tag_builder("p")
+ link = tag_builder("a")
+ bold = tag_builder("b")
+
+ puts title["Test"]
+ puts para["This is a paragraph"]
+ puts link["A link", :href => "http://foo.com"]
+ puts para[bold["Bold text with", link["a link", :href => "http://bar.com"], "inside a paragraph."]]
+
+This is the output it produces:
+
+ <h1>Test</h1>
+ <p>This is a paragraph</p>
+ <a href="http://foo.com">A link</a>
+ <p><b>Bold text with <a href="http://bar.com">a link</a> inside a paragraph.</b></p>
+
+Your challenge is implementing the `tag_builder` method used above, so you can go and build friendly HTML DSLs for your non-techy friends.
Please sign in to comment.
Something went wrong with that request. Please try again.