Manage markup close to home... right in the model! Caching, validation, etc
License
technicalpickles/has_markup
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
= 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
About
Manage markup close to home... right in the model! Caching, validation, etc
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published