Created
July 6, 2011 17:46
-
-
Save inky/1067860 to your computer and use it in GitHub Desktop.
Jekyll plugin to selectively allow blog posts to use PHP.
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
Jekyll plugin to selectively allow blog posts to use PHP. | |
Copy php_posts.rb to your _plugins folder. Set 'php: yes' on a post, and | |
Jekyll will generate an 'index.php' file for it (rather than 'index.html'). | |
This has only been tested with the following permalink format: | |
/:year/:title/ |
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
# Extending the Post class. | |
# See https://github.com/mojombo/jekyll/blob/master/lib/jekyll/post.rb | |
module Jekyll | |
class Post | |
# Rewrite to allow posts with .php extensions. | |
# Just set 'php: yes' in the YAML front matter. | |
def destination(dest) | |
# The url needs to be unescaped in order to preserve the correct filename | |
path = File.join(dest, CGI.unescape(self.url)) | |
fn = (self.data['php']) ? 'index.php' : 'index.html' | |
path = File.join(path, fn) if template[/\.html$/].nil? | |
path | |
end | |
end | |
end |
Any chance you could update this to work with 3.2.1? The plugin stopped working with version 3.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This only works with permalinks set to "pretty" can you get this to work with permalinks set to "none"?