a little code cleanup
This commit is contained in:
parent
8d2366b9f5
commit
f31dd0f3d4
|
@ -11,3 +11,4 @@ module Sass::Script::Functions
|
|||
Sass::Script::String.new("body[data-action='#{action}'][data-controller='#{controller}']")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue