Skip to content

Instantly share code, notes, and snippets.

@Dru89
Created September 2, 2013 00:18
Show Gist options
  • Save Dru89/6408202 to your computer and use it in GitHub Desktop.
Save Dru89/6408202 to your computer and use it in GitHub Desktop.
module Jekyll
LIQUIDY_TAGS = ['{{', '}}', '{%', '%}']
class StaticFile
def is_liquidy
case File.extname(self.path)
when '.html'
text = File.read(self.path)
LIQUIDY_TAGS.any? { |tag| text.include? tag }
else
false
end
end
def as_page
Page.new(@site, @base, @dir, @name)
end
end
class StaticFileMigrator < Generator
safe true
priority :highest
def generate(site)
liquidy_files = site.static_files.select { |file| file.is_liquidy }
site.pages += liquidy_files.map { |static_file| static_file.as_page }
site.static_files -= liquidy_files
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment