Created
September 2, 2013 00:18
-
-
Save Dru89/6408202 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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