updated readme
This commit is contained in:
11
app/helpers/application_helper.rb
Normal file
11
app/helpers/application_helper.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module ApplicationHelper
|
||||
@my_blockquote = {
|
||||
'Quote' => [
|
||||
/\[quote\](.*?)\[\/quote\1?\]/mi,
|
||||
'<blockquote>\3</blockquote>',
|
||||
'Quote with citation',
|
||||
'[quote=mike]please quote me[/quote]',
|
||||
:quote
|
||||
],
|
||||
}
|
||||
end
|
||||
23
app/helpers/error_messages_helper.rb
Normal file
23
app/helpers/error_messages_helper.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
module ErrorMessagesHelper
|
||||
# Render error messages for the given objects. The :message and :header_message options are allowed.
|
||||
def error_messages_for(*objects)
|
||||
options = objects.extract_options!
|
||||
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
|
||||
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
|
||||
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
|
||||
unless messages.empty?
|
||||
content_tag(:div, :class => "error_messages") do
|
||||
list_items = messages.map { |msg| content_tag(:li, msg) }
|
||||
content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module FormBuilderAdditions
|
||||
def error_messages(options = {})
|
||||
@template.error_messages_for(@object, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
|
||||
22
app/helpers/layout_helper.rb
Normal file
22
app/helpers/layout_helper.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# These helper methods can be called in your template to set variables to be used in the layout
|
||||
# This module should be included in all views globally,
|
||||
# to do so you may need to add this line to your ApplicationController
|
||||
# helper :layout
|
||||
module LayoutHelper
|
||||
def title(page_title, show_title = true)
|
||||
content_for(:title) { h(page_title.to_s) }
|
||||
@show_title = show_title
|
||||
end
|
||||
|
||||
def show_title?
|
||||
@show_title
|
||||
end
|
||||
|
||||
def stylesheet(*args)
|
||||
content_for(:head) { stylesheet_link_tag(*args) }
|
||||
end
|
||||
|
||||
def javascript(*args)
|
||||
content_for(:head) { javascript_include_tag(*args) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user