Created
June 21, 2017 14:46
-
-
Save DougBeney/b9382db03980f94d1969baf5caee909b to your computer and use it in GitHub Desktop.
Jekyll Pug Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## 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