lib/table_setter/table.rb in table_setter-0.1.7 vs lib/table_setter/table.rb in table_setter-0.1.8

- old
+ new

@@ -98,11 +98,11 @@ end # A convienence method to return the sort array for table setter. def sort_array @data.sorted_by.inject([]) do |memo, (key, value)| - memo << [@data.columns.index(key), value == 'descending' ? 0 : 1] + memo << [@data.columns.index(key), value == 'descending' ? 1 : 0] end end # We magically need access to the top level keys like google_key, or uri for the other methods. # It's a bit dangerous because everything returns nil otherwise. At some point we should eval @@ -220,7 +220,21 @@ if percent < 1 percent = percent * 100 end "<div class=\"bar\" style=\"width:#{percent}%\">#{percent}%</div>" end + # markdown formatting in tablefu cells + def markdown(cell) + RDiscount.new(cell).to_html + end + # format as a link, if the href is empty don't make the link active + def link(linkname, href) + title = linkname.to_s.gsub(/(["])/, "'") + if !href.value.nil? && !href.value.empty? + "<a href=\"#{href}\" title=\"#{title}\">#{linkname}</a>" + else + "<a title=\"#{title}\">#{linkname}</a>" + end + end + end end