instance method complex_template

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

complex_template(relative_source, relative_destination, template_options = {})

No documentation comment.

Parameters

relative_source req
relative_destination req
template_options opt = {}
Source
# File railties/lib/rails_generator/commands.rb, line 587
        def complex_template(relative_source, relative_destination, template_options = {})

           begin
             dest_file = destination_path(relative_destination)
             source_to_update = File.readlines(dest_file).join
           rescue Errno::ENOENT
             logger.missing relative_destination
             return
           end

           logger.refreshing "#{template_options[:insert].gsub(/\.erb/,'')} inside #{relative_destination}"

           begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id]))
           end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id]))

           # Refreshing inner part of the template with freshly rendered part.
           rendered_part = render_template_part(template_options)
           source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part)

           File.open(dest_file, 'w') { |file| file.write(source_to_update) }
        end

Defined in railties/lib/rails_generator/commands.rb line 587 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generator::Commands::Update

Type at least 2 characters to search.

↑↓ navigate · open · esc close