module Sinatra::Footnotes::Helpers
Public Instance Methods
close_helper(note)
click to toggle source
Process notes to get javascript code to close them.
# File lib/sinatra-footnotes.rb, line 15 def close_helper(note) "Footnotes.hide(document.getElementById('#{note.to_sym}_debug_info'));\n" end
each_with_rescue(notes) { |note| ... }
click to toggle source
# File lib/sinatra-footnotes.rb, line 31 def each_with_rescue(notes) notes.each do |note| begin yield note rescue Exception => e STDERR.puts "FootNotes #{note.to_s.camelize}NoteException" STDERR.puts e end end end
fieldsets(notes)
click to toggle source
# File lib/sinatra-footnotes.rb, line 42 def fieldsets(notes) content = '' each_with_rescue(notes) do |note| next unless note.has_fieldset? content << <<-HTML <fieldset id="#{note.to_sym}_debug_info" style="display: none"> <legend>#{note.legend}</legend> <div>#{note.content}</div> </fieldset> HTML end content end
link_helper(note)
click to toggle source
Helper that creates the link and javascript code when note is clicked
# File lib/sinatra-footnotes.rb, line 21 def link_helper(note) onclick = note.onclick unless href = note.link href = '#' onclick ||= "Footnotes.hideAllAndToggle('#{note.to_sym}_debug_info');return false;" if note.has_fieldset? end "<a href=\"#{href}\" onclick=\"#{onclick}\">#{note.title}</a>" end