Skip to content

Instantly share code, notes, and snippets.

@DougBeney
Created June 21, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougBeney/b9382db03980f94d1969baf5caee909b to your computer and use it in GitHub Desktop.
Save DougBeney/b9382db03980f94d1969baf5caee909b to your computer and use it in GitHub Desktop.
Jekyll Pug Plugin
##
## This Plugin enables Pug support to pages and posts.
##
require 'open3'
module Jekyll
class PugConverter < Converter
def matches(ext)
ext =~ /^\.pug$/i
end
def output_ext(ext)
".html"
end
def convert(content)
begin
o, e, s = Open3.capture3("pug", :stdin_data => content)
puts(<<-eos
Pug Error >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#{e}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Pug Error
eos
) if e.length > 0
rescue Errno::ENOENT => e
puts "** ERROR: Pug isn't installed or could not be found."
puts "** ERROR: To install with NPM run: npm install pug -g"
return nil
end
return o
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment