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}']")
|
Sass::Script::String.new("body[data-action='#{action}'][data-controller='#{controller}']")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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() {
|
||||||
|
18
lib/bullseye/tilt/find_parts.rb
Normal file
18
lib/bullseye/tilt/find_parts.rb
Normal 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user