Sha256: d1447c2c5685058ad803ffe5459b0f6f83c1701adc3509124a6eabe1cd7a2f4e
Contents?: true
Size: 1023 Bytes
Versions: 2
Compression:
Stored size: 1023 Bytes
Contents
module Slippery module ProcessorHelpers def self.included(klz) klz.extend ClassMethods end def asset_uri(path) "file://" + Slippery::ROOT.join('assets', path).to_s end def include_local_javascript(element, path) element.add javascript_include_tag(path) end def include_local_css(element, path) element.add stylesheet_link_tag(path) end def javascript_include_tag(path) H[:script, {src: path, type: 'text/javascript'}] end def stylesheet_link_tag(path) H[:link, {href: path, rel: 'stylesheet'}] end def data_attributes(attrs) Hash[*attrs.flat_map { |k, v| ["data-#{k}", v] }] end module ClassMethods def processor(name, selector = nil, &blk) if selector define_method name do ->(node) { node.replace(selector) { |node| instance_exec(node, &blk) } } end else define_method name { ->(node) { blk.call(node) } } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slippery-0.3.0 | lib/slippery/processor_helpers.rb |
slippery-0.2.0 | lib/slippery/processor_helpers.rb |