module Slippery::ProcessorHelpers
Public Class Methods
asset_uri(path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 7 def asset_uri(path) "file://" + Slippery::ROOT.join('assets', path).to_s end
included(klz)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 3 def self.included(klz) klz.extend ClassMethods end
Public Instance Methods
call(doc)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 36 def call(doc) doc.process(*self.class.processors.map {|name| send(name) }) end
data_attributes(attrs)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 28 def data_attributes(attrs) Hash[*attrs.flat_map { |k, v| ["data-#{k}", v] }] end
hash_to_js(hsh)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 32 def hash_to_js(hsh) hsh.map { |k, v| "#{k}:#{v.inspect}" }.join(',') #:( end
include_local_css(element, path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 16 def include_local_css(element, path) element.add stylesheet_link_tag(asset_uri(path)) end
include_local_javascript(element, path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 12 def include_local_javascript(element, path) element.add javascript_include_tag(asset_uri(path)) end
javascript_include_tag(path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 20 def javascript_include_tag(path) H[:script, {src: path, type: 'text/javascript'}] end
stylesheet_link_tag(path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 24 def stylesheet_link_tag(path) H[:link, {href: path, rel: 'stylesheet'}] end
Private Instance Methods
asset_uri(path)
click to toggle source
# File lib/slippery/processor_helpers.rb, line 7 def asset_uri(path) "file://" + Slippery::ROOT.join('assets', path).to_s end