Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added processor code for string interpolation. Fixes GH-6

  • Loading branch information...
commit cc0c1e308ae02d8bead27ec5baebdcd8233d7407 1 parent 6fb855a
Ryan Bigg radar authored
3  explanations/interpolation.md
Source Rendered
... ... @@ -0,0 +1,3 @@
  1 +## String Interpolation
  2 +
  3 +When using double quoted (`"`) strings, you can dynamically add more content by using a process called interpolation. Any content inside a double quoted string wrapped in `#{}` will be evaluated and the output added to the string which contains it.
2  fixtures/interpolation.rb
... ... @@ -0,0 +1,2 @@
  1 +a = "foo"
  2 +puts "This is an interpolated #{a} string"
7 processor.rb
@@ -143,7 +143,7 @@ def process_lit(exp)
143 143 super
144 144 end
145 145 end
146   -
  146 +
147 147 CALLS = [:require, :attr_accessor, :attr_reader, :attr_writer, :include, :extend]
148 148 SPECIALS = [:colon2]
149 149
@@ -152,6 +152,11 @@ def process_call(exp)
152 152 mark(exp[1]) + super
153 153 elsif !exp[0].nil? and SPECIALS.include? exp[0][0]
154 154 mark(exp[0][0]) + super
  155 + # All this crap for string interpolation.
  156 + elsif exp[2] && exp[2][1].sexp_type == :dstr
  157 + if !exp[2][1].find_nodes(:evstr).empty?
  158 + mark(:interpolation) + super
  159 + end
155 160 else
156 161 super
157 162 end

0 comments on commit cc0c1e3

Please sign in to comment.
Something went wrong with that request. Please try again.