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}']")
end
end

View File

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