Sha256: 8a2c5e214859740b6898cb759dba4a20ab6bbc447c24ece9b6dbf8a36803af99
Contents?: true
Size: 828 Bytes
Versions: 9
Compression:
Stored size: 828 Bytes
Contents
class ViewGenerator < Rails::Generators::NamedBase desc "Adds some view code to existing View" argument :view, :type => :string, :required => true argument :ext, :type => :string, :default => 'html.erb' def self.source_root @source_root ||= File.expand_path("../templates", __FILE__) end def add_helper_method if File.exist?(view_file_name) inject_into_file(view_file_name, view_code, :after => after_txt) if after_txt else say "#{view_file_name} does not exist. Please create it first before you can add view code to it!", :red end end protected def after_txt '# view content' end def view_file_name File.join(Rails.root, "app/views/#{file_name}/#{view}.#{ext}") end def view_code %Q{ <%= "Hello You" %> } end end
Version data entries
9 entries across 9 versions & 1 rubygems