helpers.rb 854 字节
Newer Older
1 2 3 4 5 6
module RailsGuides
  module Helpers
    def guide(name, url, options = {}, &block)
      link = content_tag(:a, :href => url) { name }
      result = content_tag(:dt, link)

7 8
      if options[:work_in_progress]
        result << content_tag(:dd, 'Work in progress', :class => 'work-in-progress')
9 10 11
      end

      result << content_tag(:dd, capture(&block))
12
      result
13 14 15 16 17
    end

    def author(name, nick, image = 'credits_pic_blank.gif', &block)
      image = "images/#{image}"

18
      result = content_tag(:img, nil, :src => image, :class => 'left pic', :alt => name, :width => 91, :height => 91)
19 20
      result << content_tag(:h3, name)
      result << content_tag(:p, capture(&block))
21
      content_tag(:div, result, :class => 'clearfix', :id => nick)
22 23 24 25 26 27 28 29
    end

    def code(&block)
      c = capture(&block)
      content_tag(:code, c)
    end
  end
end