Sha256: 1efb89316bb039b2778d82380027e04da7d69e1c2618df844f43a1afe8aa509f
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
class ViewGenerator < Rails::Generators::NamedBase include Rails3::Assist::Generators::BasicHelper 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
generator-spec-0.7.1 | spec/generator_spec/fixtures/generators/view/view_generator.rb |
generator-spec-0.7.0 | lib/generators/view/view_generator.rb |