Sha256: b8a41a62444cc54823ae983e6e078c1bd863ed463bad90329a42ac9f31d40d40
Contents?: true
Size: 1.94 KB
Versions: 2
Compression:
Stored size: 1.94 KB
Contents
require "generators/html5/generator_helpers" module Html5 module Generators class AssetsGenerator < ::Rails::Generators::NamedBase include Html5::Generators::GeneratorHelpers source_root File.expand_path('../templates', __FILE__) argument :name, :type => :string, :required => false, :default => "application" def generate_javascripts asset_path = "app/assets/javascripts/#{ asset_name }.js" if File.exist?(asset_path) && File.read(asset_path) =~ /require jquery_ujs$/ inject_into_file asset_path, :after => "require jquery_ujs" do "\n//= require h5bp" end gsub_file asset_path, /^\/\/= require_tree \.(\\n)?/, "" else template "javascripts/application.js", asset_path end template "javascripts/polyfills.js", "app/assets/javascripts/polyfills.js" end def generate_stylesheets if file_path == "application" remove_file "app/assets/stylesheets/application.css" end file_ext = ".css.scss" copy_file "stylesheets/_defaults#{ file_ext }", "app/assets/stylesheets/_defaults#{ file_ext }" template "stylesheets/application#{ file_ext }", File.join("app/assets/stylesheets", asset_name + file_ext) end def generate_stylesheet_partials if stylesheet_partials.any? empty_directory File.join("app/assets/stylesheets", asset_name) end file_ext = ".css.scss" stylesheet_partials.each do |partial| template File.join("stylesheets/application", partial + file_ext), File.join("app/assets/stylesheets", asset_name, partial + file_ext) end end # TODO # def add_precompiles # end protected def asset_name (class_path + [file_name]).join('_') end def stylesheet_partials %w(_defaults document media_queries) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html5-rails-0.0.4 | lib/generators/html5/assets/assets_generator.rb |
html5-rails-0.0.3 | lib/generators/html5/assets/assets_generator.rb |