Would .html.erb files get interpreted
iamdriz opened this issue · 2 comments
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?
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?
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.