Sha256: 9264b3f9a7f367507194ddd6709516cf5c4cc6e9793eb5cf80157d36f7eef0ef

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

module MyForum
  module PostsHelper
    def format_post_text(post)
      text = post.text

      # Images
      text.gsub!(/\[img\]/i,   '<img src="')
      text.gsub!(/\[\/img\]/i, '" />')

      # Bold text
      text.gsub!(/\[b\]/i,   '<strong>')
      text.gsub!(/\[\/b\]/i, '</strong>')

      # Quote
      # text.gsub!(/\[quote.*]/i, '<span class="bbqoute">')
      # text.gsub!(/\[\/quote\]/i, '</span>')
      text.gsub!(/\[quote.*]/i, 'quote:')
      text.gsub!(/\[\/quote\]/i, '')

      # Link
      #text.scan(/(?<url>\[url=(.*?)\])(?<url_text>.*?)\[\/url\]/) {|m| puts m.first}
      #text.match(/(?<url>\[url=(.*?)\])(?<url_text>.*?)\[\/url\]/)
      #\[url=(.*?)\](.*?)\[\/url\]
      text.gsub!(/\[url=(.*?)\](.*?)\[\/url\]/i) { "<a href='#{$1}'>#{$2}</a>" }

      text.html_safe
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_forum-0.0.1.beta1 app/helpers/my_forum/posts_helper.rb