module HtmlSlicer
Constants
- VERSION
Public Class Methods
config(style = nil)
click to toggle source
Config accessor for HtmlSlicer
. Accepts argument as a style
.
# File lib/html_slicer/config.rb, line 41 def self.config(style = nil) eval("@config#{"_#{style}" if style}") || raise("Config style '#{style}' is invalid.") end
configure(style = nil) { |eval("config#{"_#{style}"| ... }
click to toggle source
Configures global settings for HtmlSlicer
Default global configuration options¶ ↑
window = 4 outer_window = 0 left = 0 right = 0 param_name = :slice
Override/complete global configuration¶ ↑
HtmlSlicer.configure do |config| config.slice = {:complete => /\s+|\z/, :maximum => 2000} config.resize = {:width => 300, :only => {:tag => 'iframe'}} config.window = 5 config.param_name = :any_other_param_name end
Passing an argument (:symbol) creates stylized configuration, which can be used like that:¶ ↑
HtmlSlicer.configure(:paged) do |config| config.as = :page config.param_name = :page end class Post < ActiveRecord::Base slice :content, :config => :paged end
-
Missing options are inherited from global one.
# File lib/html_slicer/config.rb, line 36 def self.configure(style = nil, &block) yield eval("@config#{"_#{style}" if style} ||= #{style ? "@config.duplicate" : "Configuration.new"}") end
load!()
click to toggle source
# File lib/html_slicer.rb, line 6 def self.load! require 'html_slicer/utilities' require 'html_slicer/config' require 'html_slicer/interface' require 'html_slicer/engine' require 'html_slicer/helpers/action_view_extension' require 'html_slicer/helpers/slicer' require 'html_slicer/railtie' end
load_processor!(name)
click to toggle source
# File lib/html_slicer/processor.rb, line 27 def self.load_processor!(name) if defined?(Rails.root) && Rails.root require File.expand_path(Rails.root.join("lib", "html_slicer_processors", "#{name.to_s.underscore}.rb")) end end