diff --git a/lib/step.rb b/lib/step.rb index ca08aa0e9..bcabb10f3 100644 --- a/lib/step.rb +++ b/lib/step.rb @@ -99,9 +99,12 @@ def step name = nil, options = {} end end - def link name + + def link name, options = {} + options = {caption: LINK_CAPTION}.merge(options) p :class => "link" do - text "Go on to " + text options[:caption] + text " " simple_link(name, class: :link) end end @@ -242,6 +245,7 @@ def tip text = nil, &block IRB_CAPTION = "Type this in irb:" RESULT_CAPTION = "Expected result:" FUZZY_RESULT_CAPTION = "Approximate expected result:" + LINK_CAPTION = "Go on to" def console(commands) console_with_message(TERMINAL_CAPTION, commands) diff --git a/sites/en/learn-to-code/learn-to-code.step b/sites/en/learn-to-code/learn-to-code.step index efc4e4bc0..e0d3885d8 100644 --- a/sites/en/learn-to-code/learn-to-code.step +++ b/sites/en/learn-to-code/learn-to-code.step @@ -1,19 +1,20 @@ - -link "learn_to_code" -link "computers" -link "objects" -link "strings" -link "numbers" -link "variables" -link "nil" -link "the_command_line" -link "input_and_output" -link "logic" -link "loops" -link "arrays" -link "argv" -link "hashes" -link "functions" -link "sinatra" -link "extra" -link "next_steps" +ul do + li { link "learn_to_code", caption: "" } + li { link "computers", caption: "" } + li { link "objects", caption: "" } + li { link "strings", caption: "" } + li { link "numbers", caption: "" } + li { link "variables", caption: "" } + li { link "nil", caption: "" } + li { link "the_command_line", caption: "" } + li { link "input_and_output", caption: "" } + li { link "logic", caption: "" } + li { link "loops", caption: "" } + li { link "arrays", caption: "" } + li { link "argv", caption: "" } + li { link "hashes", caption: "" } + li { link "functions", caption: "" } + li { link "sinatra", caption: "" } + li { link "extra", caption: "" } + li { link "next_steps", caption: "" } +end diff --git a/spec/step_spec.rb b/spec/step_spec.rb index 705a189e8..a38bffc52 100644 --- a/spec/step_spec.rb +++ b/spec/step_spec.rb @@ -94,6 +94,15 @@ def step_obj_for(path) hash = URI.escape '#' assert { a["href"] == "choose_breakfast?back=hello#{hash}step1" } end + + it "has an optional parameter for the caption" do + html_doc(<<-RUBY) + step "breakfast" do + link "breakfast", caption: "Eat some" + end + RUBY + assert { html_doc.css("p.link").text == "Eat some Breakfast" } + end end describe 'source_code' do