Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technicalpickles/has_markup
Manage markup close to home... right in the model! Caching, validation, etc
https://github.com/technicalpickles/has_markup
Last synced: 2 months ago
JSON representation
Manage markup close to home... right in the model! Caching, validation, etc
- Host: GitHub
- URL: https://github.com/technicalpickles/has_markup
- Owner: technicalpickles
- License: mit
- Created: 2008-07-04T04:55:36.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2010-03-08T03:32:03.000Z (almost 15 years ago)
- Last Synced: 2024-10-14T21:50:43.653Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 266 KB
- Stars: 14
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
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 theSo, you can use it in your view:
<%= h @post.title %>
<%= @post.cached_content_html %>
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