Last Updated: February 25, 2016
·
1.805K
· billwatts

Slim templates in Octopress

Love using Slim templates? Love Octopress? Want to hook these crazy kids up? That's what I was looking for this weekend.

module Jekyll
  require 'slim'
  class SlimConverter < Converter
    safe true
    priority :low

    def matches(ext)
      ext =~ /slim/i
    end

    def output_ext(ext)
      ".html"
    end

    def convert(content)
      begin
        Slim::Template.new { content }.render
      rescue StandardError => e
        puts "!!! SLIM Error: " + e.message
      end
    end
  end
end

Just add that to a new file and save it in the plugins folder of your Octopress site. Boom, now you can render your slim templates to static html.

Credit where credit is due: http://yobriefca.se/blog/2012/03/22/slim-generator-for-octopress/

1 Response
Add your response

Can i use slim in gh-pages ?

over 1 year ago ·