Method: EtchExternalSource#process_template
- Defined in:
- lib/etch.rb
#process_template(template) ⇒ Object
This method processes an ERB template (as specified via a <template> entry in a config.xml file) and returns the results.
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
# File 'lib/etch.rb', line 2032 def process_template(template) @dlogger.debug "Processing template #{template} for file #{@file}" # The '-' arg allows folks to use <% -%> or <%- -%> to instruct ERB to # not insert a newline for that line, which helps avoid a bunch of blank # lines in the processed file where there was code in the template. erb = ERB.new(IO.read(template), nil, '-') # The binding arg ties the template's namespace to this point in the # code, thus ensuring that all of the variables above (@file, etc.) # are visible to the template code. begin erb.result(binding) rescue Exception => e # Help the user figure out where the exception occurred, otherwise they # just get told it happened here, which isn't very helpful. raise Etch.wrap_exception(e, "Exception while processing template #{template} for file #{@file}:\n" + e.) ensure restore_globals end end |