class Middleman::Galley::Template

Constants

IMG

Public Class Methods

[](name) click to toggle source
# File lib/middleman/galley/template.rb, line 8
def self.[] name
  name = name.to_sym
  @@known[name]
end
build(context) click to toggle source
# File lib/middleman/galley/template.rb, line 18
def self.build context
  new(context).build
end
new(context) click to toggle source
# File lib/middleman/galley/template.rb, line 22
def initialize context
  @context = context
end
register(name) click to toggle source
# File lib/middleman/galley/template.rb, line 13
def self.register name
  name = name.to_sym
  @@known[name] = self
end

Private Instance Methods

a() click to toggle source
# File lib/middleman/galley/template.rb, line 29
def a # rid?
  @context
end
children() click to toggle source
# File lib/middleman/galley/template.rb, line 33
def children
  @context.current_page.children
end
image(res) click to toggle source
# File lib/middleman/galley/template.rb, line 41
def image res
  return nil unless image? res
  url = if a.relative_links
          relative res.url
        else
          res.url
        end
  w, h = FastImage.size res.source_file
  a.tag :img, src: url, width: w, height: h
end
image?(res) click to toggle source
# File lib/middleman/galley/template.rb, line 53
def image? res
  res.source_file =~ IMG
end
image_tags() click to toggle source
# File lib/middleman/galley/template.rb, line 37
def image_tags
  children.sort_by(&:url).map { |x| image x }.compact
end
relative(url) click to toggle source
# File lib/middleman/galley/template.rb, line 57
def relative url
  url.sub a.current_page.url, ''
end