Method: Warg::Script::Template#compile

Defined in:
lib/warg.rb

#compile(interpolations) ⇒ Object



2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
# File 'lib/warg.rb', line 2189

def compile(interpolations)
  @content.gsub(INTERPOLATION_REGEXP) do |match|
    if interpolations.key?($1)
      interpolations[$1]
    else
      $stderr.puts "[WARN] `#{$1}' is not defined in interpolations or context variables"
      $stderr.puts "[WARN]   leaving interpolation `#{match}' as is"
      match
    end
  end
end