Module: Blogit::ApplicationHelper
- Defined in:
- app/helpers/blogit/application_helper.rb
Constant Summary
- TIMETAG_FORMAT =
"%Y-%m-%dT%TZ"
Instance Method Summary (collapse)
-
- (Object) actions(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'actions' Used for option links and form buttons.
-
- (Object) errors_on(object, attribute)
Returns the first error message for an ActiveRecord model instance.
-
- (Object) field(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'field' Used for separating form fields.
-
- (Object) format_content(content = nil, &block)
Format content using the default_parser_class.
-
- (Object) login_required(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'login_required' Will only render content if there is a logged in user.
-
- (Object) method_missing(method, *args, &block)
Can search for named routes directly in the main app, omitting the "main_app." prefix.
- - (Boolean) respond_to?(method)
-
- (Object) time_tag(time_object, format = nil, options = {})
Returns an HTML 5 time tag.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
Can search for named routes directly in the main app, omitting the "main_app." prefix
62 63 64 65 66 67 68 |
# File 'app/helpers/blogit/application_helper.rb', line 62 def method_missing method, *args, &block if main_app_url_helper?(method) main_app.send(method, *args) else super end end |
Instance Method Details
- (Object) actions(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'actions' Used for option links and form buttons
30 31 32 |
# File 'app/helpers/blogit/application_helper.rb', line 30 def actions(={}, ={}, &block) div_with_default_class(:actions, , , &block) end |
- (Object) errors_on(object, attribute)
Returns the first error message for an ActiveRecord model instance
17 18 19 20 |
# File 'app/helpers/blogit/application_helper.rb', line 17 def errors_on(object, attribute) = object.errors[attribute].first content_tag(:span, , class: "blogit_error_message") if end |
- (Object) field(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'field' Used for separating form fields
24 25 26 |
# File 'app/helpers/blogit/application_helper.rb', line 24 def field(={}, ={}, &block) div_with_default_class(:field, , , &block) end |
- (Object) format_content(content = nil, &block)
Format content using the default_parser_class
7 8 9 10 11 |
# File 'app/helpers/blogit/application_helper.rb', line 7 def format_content(content = nil, &block) content = capture(&block) if block_given? parser = Blogit::configuration.default_parser_class.new(content) parser.parsed.html_safe end |
- (Object) login_required(content_or_options = {}, options = {}, &block)
A helper method for creating a <div> tag with class 'login_required' Will only render content if there is a logged in user
36 37 38 39 40 |
# File 'app/helpers/blogit/application_helper.rb', line 36 def login_required(={}, ={}, &block) if current_blogger and blogit_conf.include_admin_links div_with_default_class(:login_required, , , &block) end end |
- (Boolean) respond_to?(method)
69 70 71 |
# File 'app/helpers/blogit/application_helper.rb', line 69 def respond_to?(method) main_app_url_helper?(method) or super end |
- (Object) time_tag(time_object, format = nil, options = {})
Returns an HTML 5 time tag
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/blogit/application_helper.rb', line 46 def time_tag(time_object, format = nil, ={}) # if there's a specified format and it's a string, assume it's an strftime string if format && format.is_a?(String) time_string = time_object.strftime(format) # if there's a specified format and it's a symbol, assume it's a predefined format elsif format && format.is_a?(Symbol) time_string = time_object.to_s(format) else time_string = time_object.to_s end .merge(datetime: time_object.strftime(TIMETAG_FORMAT)) content_tag(:time, time_string, ) end |