Sha256: 220bc8058513629c9098c3f5e20b00e54304d189eb4cfba188d60066ff254d24
Contents?: true
Size: 1.04 KB
Versions: 43
Compression:
Stored size: 1.04 KB
Contents
require "haml" module Middleman module Renderers module Haml class << self def registered(app) app.helpers Middleman::Renderers::Haml::Helpers end alias :included :registered end module Helpers def haml_partial(name, options = {}) partial(name, options) end end module Table include ::Haml::Filters::Base def render(text) output = '<div class="table"><table cellspacing="0" cellpadding="0">' line_num = 0 text.each_line do |line| line_num += 1 next if line.strip.empty? output << %Q{<tr class="#{(line_num % 2 == 0) ? "even" : "odd" }#{(line_num == 1) ? " first" : "" }">} columns = line.split("|").map { |p| p.strip } columns.each_with_index do |col, i| output << %Q{<td class="col#{i+1}">#{col}</td>} end output << "</tr>" end output + "</table></div>" end end end end end
Version data entries
43 entries across 43 versions & 2 rubygems