Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added processor code for string interpolation. Fixes GH-6

  • Loading branch information...
commit cc0c1e308ae02d8bead27ec5baebdcd8233d7407 1 parent 6fb855a
@radar radar authored
View
3  explanations/interpolation.md
@@ -0,0 +1,3 @@
+## String Interpolation
+
+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.
View
2  fixtures/interpolation.rb
@@ -0,0 +1,2 @@
+a = "foo"
+puts "This is an interpolated #{a} string"
View
7 processor.rb
@@ -143,7 +143,7 @@ def process_lit(exp)
super
end
end
-
+
CALLS = [:require, :attr_accessor, :attr_reader, :attr_writer, :include, :extend]
SPECIALS = [:colon2]
@@ -152,6 +152,11 @@ def process_call(exp)
mark(exp[1]) + super
elsif !exp[0].nil? and SPECIALS.include? exp[0][0]
mark(exp[0][0]) + super
+ # All this crap for string interpolation.
+ elsif exp[2] && exp[2][1].sexp_type == :dstr
+ if !exp[2][1].find_nodes(:evstr).empty?
+ mark(:interpolation) + super
+ end
else
super
end

0 comments on commit cc0c1e3

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