adaoraul / rack-jekyll

Transform your Jekyll app into Rack application!
http://adaoraul.github.io/rack-jekyll
MIT License
182 stars 43 forks source link

Would .html.erb files get interpreted #54

Open iamdriz opened 6 years ago

iamdriz commented 6 years ago

If I hypothetically had a file in the compiled _site directory called index.html.erb containing Ruby code. Would that Ruby code be interpreted by Rack/Puma?

iamdriz commented 6 years ago

Okay so I tried this and any files I rename to have an extension .html.erb just return 404's when I try and access them when I run the site through Rack using this gem (also noticed that in the _site directory they actually get named as .erb and lose the html part of the extension. Though apparently that's okay for ERB files.

So the next question is... is it possible to get this gem to run them? Is it a case of modifying the lib/jekyll.rb file to include require 'erb' and then do ERB.new(FILENAME).result(binding) for the return if the file extension is erb?

iamdriz commented 6 years ago

Cool so I was right you can do this using ERB and you don't even have to rename the files. All you have to do is change the code to:

        if media_type == 'text/html'
          body = ERB.new(file[:body]).result
        else
          body = file[:body]
        end

In lib/jekyll.rb.

The media_type check is required as otherwise it can screw up other files.