module Blogit module ApplicationHelper TIMETAG_FORMAT = "%Y-%m-%dT%TZ" # Creates a div tag with class 'blog_' + (post|comment) + '_' + name # Eg: # blog_tag(:title, "") # =>
# blog_tag(:email, "", {:type => "comment"}) # => # blog_tag(:tweet, "", {:type => "status"}) # => def blog_tag(name, content_or_options = {}, options = {}, &block) tag_type = options.delete(:type) || "post" if block_given? content = capture(&block) options = content_or_options else content = content_or_options end options[:class] = "#{options[:class]} blog_#{tag_type}_#{name}".strip content_tag(name, content, options) end # Format content using the {Blogit::Configuration#default_parser_class default_parser_class} 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 # Returns the first error message for an ActiveRecord model instance # @param object A model instance to check # @param attribute A symbol or string for attribute name to check for # errors def errors_on(object, attribute) error_message = object.errors[attribute].first content_tag(:span, error_message, class: "blogit_error_message") if error_message end # A helper method for creating a +