#module ApplicationHelper module Duck module Entities def left_arrow "«" end def right_arrow "»" end end module Helpers include Entities def xhtml_doctype '' end def html_with_namespace '' end def content_type_meta_tag '' end # clears any floating elements def clear '
' end def devel_mode? RAILS_ENV == 'development' end def action_name @controller.action_name end def controller_name @controller.controller_name end # spits some inline js into the template, works like form_for, i.e., don't use <%= %> # but use <% %> instead. example: # # <% inline_js do %> # alert('Oh no!') # <% end %> # # results in this template output: # # def inline_js(&blk) js = capture(&blk) concat(javascript_tag(js), blk.binding) end def textilize(text) RedCloth.new(text, [:no_span_caps, :hard_breaks]).to_html end def tx(text) textilize text end def tx_no_p(text) textilize_without_paragraph text end # use to make development notes (formatted in textile) that only show up in development mode def dev_note(text = '', &blk) if RAILS_ENV == 'development' if block_given? instruction = capture(&blk) concat("
#{tx(instruction)}
", blk.binding) else '' + tx_no_p(text) + '' end end end end end # A label_for for builder style forms module ActionView module Helpers module FormTagHelper # uses a button instead of the input tag def submit_button(value = "Save changes", options = {}) options.stringify_keys! if disable_with = options.delete("disable_with") options["onclick"] = "this.disabled=true;this.value='#{disable_with}';this.form.submit();#{options["onclick"]}" end content_tag :button, value, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys) end end class FormBuilder # use like <%= f.label_for :some_method %> in form_for builder style forms def label_for(method, content = '' ) content = method.to_s.humanize if content.empty? @template.content_tag("label", content, :for => "#{@object_name}_#{method}") end end end end # it should never have been a div ActionView::Base.field_error_proc = Proc.new {|html_tag, instance| %(#{html_tag})}