a little code cleanup

This commit is contained in:
John Bintz 2012-08-23 13:32:54 -04:00
parent 8d2366b9f5
commit f31dd0f3d4
3 changed files with 23 additions and 4 deletions

View File

@ -11,3 +11,4 @@ module Sass::Script::Functions
Sass::Script::String.new("body[data-action='#{action}'][data-controller='#{controller}']") Sass::Script::String.new("body[data-action='#{action}'][data-controller='#{controller}']")
end end
end end

View File

@ -1,9 +1,11 @@
require 'tilt' require 'tilt'
require 'sprockets' require 'bullseye/tilt/find_parts'
module Bullseye module Bullseye
module Tilt module Tilt
class BullseyeTemplate < ::Tilt::Template class BullseyeTemplate < ::Tilt::Template
include Bullseye::Tilt::FindParts
def self.default_mime_type def self.default_mime_type
'application/javascript' 'application/javascript'
end end
@ -12,9 +14,7 @@ module Bullseye
end end
def evaluate(scope, locals, &block) def evaluate(scope, locals, &block)
parts = scope.logical_path.split('/') @scope = scope
action = parts.pop
controller = parts[1..-1].join('/')
<<-JS <<-JS
Bullseye.target('#{controller}', '#{action}', function() { Bullseye.target('#{controller}', '#{action}', function() {

View File

@ -0,0 +1,18 @@
module Bullseye
module Tilt
module FindParts
def action
parts.last
end
def controller
parts[0..-2].join('/')
end
def parts
@scope.logical_path.split('/')[1..-1]
end
end
end
end