![]() Next, I created a helper method for Redcarpet in app/helpers/application_helper.rb: markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,Īnd it will convert my markdown into HTML automatically. I added two gems to my Gemfile: gem 'redcarpet' I started off with this Railscast on it, but it’s pretty outdated, so I had to consult the docs to get things working correctly. That’s when I found Redcarpet, which was developed at GitHub and does exactly what I needed. The solutionįinally, I stepped back and realized that there was probably a way to go with my original tactic and parse my Markdown blog posts into HTML. There are several options: Middleman, Frank, Nanoc, etc., but none of them could be easily integrated into an existing Rails app the way that Jekyll could with bloggy. Then I thought that maybe I could find something similar to Jekyll that uses ERB. ![]() It would have taken a long time to switch, so I eliminated that option. But in this case, I already had all my views laid out in ERB. ![]() Making things user-editable like this has become an interest of mine while I’ve been doing some freelance work for a friend who does custom Squarespace sites (yes, there is a huge market for this even though Squarespace is designed so that “anyone” can use it). It’s extracted from Shopify and is primary use is for situations where you want to allow users control over their layout in a Rails app, but don’t want to let them run amok with Ruby on your server. If I were starting from scratch, I might have tried switching my entire app over to Liquid because it’s pretty neat. As far as I can tell, there is no way to make those two play nicely together. Jekyll uses Liquid as a templating language, and I was using Rails’ out-of-the-box ERB. There is a gem for this called bloggy that works really well, but I ran into a problem when I wanted to display posts on the front page. Then, I thought that I could integrate a Jekyll blog into my existing app. ![]() At first, I was just going to have a blog model/view/controller that I managed through RailsAdmin, but I quickly realized that was going to give me a huge block of text with no formatting whatsoever, which wasn’t going to work in a code-heavy blog. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |