Skip to content

Instantly share code, notes, and snippets.

@stefanoverna
Created October 7, 2014 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanoverna/8667f36edaff9220d252 to your computer and use it in GitHub Desktop.
Save stefanoverna/8667f36edaff9220d252 to your computer and use it in GitHub Desktop.
KSS
require 'kss'
styleguide = Kss::Parser.new('app/assets/stylesheets')
puts styleguide.sections
module Renderer
def self.render options = {}
assigns = options.delete(:assigns) || {}
view = view_class.new ActionController::Base.view_paths, assigns
view.extend ApplicationHelper
view.extend CustomHelper
view.render options
end
# Creates a subclass of ActionView::Base with route helpers mixed in.
def self.view_class
@view_class ||= Class.new ActionView::Base do
include Rails.application.routes.url_helpers
end
end
end
namespace :styleguide do
task :sync do
config = Rails.application.config.assets
# dir = File.join(Rails.public_path, config.prefix)
# puts Dir[dir + "/*"].join("\n")
manifest = Sprockets::Manifest.new(
ActionView::Base.assets_manifest.environment,
ActionView::Base.assets_manifest.dir
)
puts manifest.assets.inspect
puts manifest.files.inspect
end
end
if Rake::Task.task_defined?("assets:precompile:nondigest")
Rake::Task["assets:precompile:nondigest"].enhance do
Rake::Task["styleguide:sync"].invoke
end
else
Rake::Task["assets:precompile"].enhance do
Rake::Task["styleguide:sync"].invoke
end
end
@stefanoverna
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment