public
Rubygem
Description: Manage markup close to home... right in the model! Caching, validation, etc
Clone URL: git://github.com/technicalpickles/has_markup.git
name age message
file .gitignore Sun Aug 03 21:49:01 -0700 2008 Updated .gitignore. [technicalpickles]
file MIT-LICENSE Thu Jul 03 21:57:39 -0700 2008 FIRST COMMIT [technicalpickles]
file README Sun Oct 12 22:03:07 -0700 2008 Cleaned up comments and README. Include README ... [technicalpickles]
file Rakefile Sun Oct 12 22:03:07 -0700 2008 Cleaned up comments and README. Include README ... [technicalpickles]
file has_markup.gemspec Sun Oct 12 22:05:31 -0700 2008 Version bump. [technicalpickles]
file init.rb Fri Aug 01 14:50:03 -0700 2008 Refactored how ActiveRecord::Base gets extended. [technicalpickles]
directory lib/ Sun Oct 12 22:05:31 -0700 2008 Version bump. [technicalpickles]
directory tasks/ Thu Jul 03 21:57:39 -0700 2008 FIRST COMMIT [technicalpickles]
directory test/ Sun Oct 12 21:52:17 -0700 2008 Comment cleanup. Changed before_save callback c... [technicalpickles]
directory vendor/ Sat Oct 11 22:35:49 -0700 2008 Try vendored shoulda. [technicalpickles]
README
= HasMarkup

I don't know about you, but I'm not too much of a fan of writing out raw HTML when I'm trying to belt out some blog 
posts. Keeping track of those pesky closing tags, escaping entities, and so on, can really get in the way of your 
creativity.

As a result, most blogs provide a simplified markup or some sort of editor. For 
technicalpickles.com[http://technicalpickles.com], I went with markdown[http://daringfireball.net/projects/markdown/].

I extracted this markup magic out of my blog, and this plugin is the result. It lets you:

 * Specify a column contains markup
 * Specify the syntax (markdown and textile, with markdown being the default)
 * Specify if the markup column is required
 * Generate a helper for generating the HTML
 * Specify if the HTML should be cached in the database
 * ... all using only one line

== Example

In your model:

  class Post
    has_markup :content, :syntax => :markdown, :required => true, :cache_html => true
  end
  
Now post will have a 'content_html' method for generating the

So, you can use it in your view:

  <h2><%= h @post.title %></h2>
  <div>
    <%= @post.cached_content_html %>
  </div>

And you can test it easily using Shoulda:

  require 'has_markup/shoulda'
  class PostTest < Test::Unit::TestCase
    should_have_markup :content, :syntax => :markdown, :required => true, :cache_html => true
  end

== License

Copyright (c) 2008 Josh Nichols, released under the MIT license