add basename and name variables for static files

This commit is contained in:
Frank Taillandier 2016-08-27 11:22:24 +02:00
parent 349569592e
commit a9da814f17
No known key found for this signature in database
GPG Key ID: E73258E3F50AEB7E
3 changed files with 13 additions and 3 deletions

View File

@ -97,7 +97,8 @@ module Jekyll
def to_liquid
{
"name" => File.basename(name, extname),
"basename" => File.basename(name, extname),
"name" => name,
"extname" => extname,
"modified_time" => modified_time,
"path" => File.join("", relative_path)

View File

@ -42,7 +42,15 @@ following metadata:
<td><p><code>file.name</code></p></td>
<td><p>
The string name of the file without the extension, e.g. <code>image</code> for <code>image.jpg</code>
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

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