class Lookbook::PreviewExample
def full_template_path(template_path)
def full_template_path(template_path) base_path = Array(Lookbook.config.preview_paths).detect do |p| Dir["#{p}/#{template_path}.html.*"].first end Pathname.new(Dir["#{base_path}/#{template_path}.html.*"].first) end
def hierarchy_depth
def hierarchy_depth @preview.lookbook_hierarchy_depth + 1 end
def id
def id path.underscore.tr("_", "-") end
def initialize(name, preview)
def initialize(name, preview) @name = name @preview = preview end
def label
def label lookbook_label.presence || name.titleize end
def matchers
def matchers [@preview.label, label].map { |m| m.gsub(/\s/, "").downcase } end
def method_source
def method_source code_object.source.split("\n")[1..-2].join("\n").strip_heredoc end
def path
def path "#{@preview.lookbook_path}/#{name}" end
def source_lang
def source_lang Lookbook::Lang.find(:ruby) end
def taggable_object_path
def taggable_object_path "#{@preview.name}##{name}" end
def template_lang(template_path)
def template_lang(template_path) Lookbook::Lang.guess(full_template_path(template_path)) || Lookbook::Lang.find(:html) end
def template_source(template_path)
def template_source(template_path) File.read(full_template_path(template_path)) end
def type
def type :example end