Merge pull request #5264 from DirtyF/static-file-name

Merge pull request 5264
This commit is contained in:
jekyllbot 2016-09-29 14:13:31 -07:00 committed by GitHub
commit ef3f9d0e7a
3 changed files with 23 additions and 3 deletions

View File

@ -1,6 +1,6 @@
module Jekyll
class StaticFile
attr_reader :relative_path, :extname
attr_reader :relative_path, :extname, :name
class << self
# The cache of last modification times [path] -> mtime.
@ -97,6 +97,8 @@ module Jekyll
def to_liquid
{
"basename" => File.basename(name, extname),
"name" => name,
"extname" => extname,
"modified_time" => modified_time,
"path" => File.join("", relative_path)

View File

@ -26,7 +26,7 @@ following metadata:
<td><p><code>file.path</code></p></td>
<td><p>
The relative path to the file.
The relative path to the file, e.g <code>/assets/img/image.jpg</code>
</p></td>
</tr>
@ -34,7 +34,23 @@ following metadata:
<td><p><code>file.modified_time</code></p></td>
<td><p>
The `Time` the file was last modified.
The `Time` the file was last modified, e.g <code>2016-04-01 16:35:26 +0200</code>
</p></td>
</tr>
<tr>
<td><p><code>file.name</code></p></td>
<td><p>
The string name of the file e.g. <code>image.jpg</code> for <code>image.jpg</code>
</p></td>
</tr>
<tr>
<td><p><code>file.basename</code></p></td>
<td><p>
The string basename of the file e.g. <code>image</code> for <code>image.jpg</code>
</p></td>
</tr>

View File

@ -142,6 +142,8 @@ class TestStaticFile < JekyllUnitTest
should "be able to convert to liquid" do
expected = {
"basename" => "static_file",
"name" => "static_file.txt",
"extname" => ".txt",
"modified_time" => @static_file.modified_time,
"path" => "/static_file.txt"