lib/sprockets/source_line.rb in sstephenson-sprockets-0.1.1 vs lib/sprockets/source_line.rb in sstephenson-sprockets-0.3.0
- old
+ new
@@ -14,18 +14,37 @@
def comment?
!!comment
end
+ def begins_multiline_comment?
+ line =~ /^\s*\/\*\*(.*)/
+ end
+
+ def closes_multiline_comment?
+ line =~ /^(.*)*\*\*\/\s*/
+ end
+
def require
@require ||= (comment || "")[/^=\s+require\s+(\"(.*?)\"|<(.*?)>)\s*$/, 1]
end
def require?
!!require
end
def inspect
"line #@number of #{@source_file.pathname}"
+ end
+
+ def to_s(constants = source_file.environment.constants)
+ line.chomp.gsub(/<%=(.*?)%>/) do
+ constant = $1.strip
+ if value = constants[constant]
+ value
+ else
+ raise UndefinedConstantError, "couldn't find constant `#{constant}' in #{inspect}"
+ end
+ end + $/
end
end
end