Get Files
Retrieve and filter a list of files.
Example
Iterate through the Javascript files in your theme:
{{ get_files in="site/themes/redwood/js" }}
<script src="{{ file }}"></script>
{{ /get_files }}
Parameters
|
in|from
string |
The directory from which to find files. Relative to your project root. For example: |
|---|---|
|
depth
integer 1 |
The depth of subdirectories to recursively look through. Defaults to no recursion. |
|
not_in
string |
Filter by excluding from a subdirectory or subdirectories. You may use regex, and will be matched against the file path without a leading slash. For example: |
|
file_size
string |
Filter by file size using one of the following comparison operators. >, >=, <, <=, ==, !=. For example: |
|
ext|extension
string |
Filter by file extension. You may pipe delimit multiple extensions. |
|
include|match
regex |
Filter files by a regular expression. Matches will be kept in the list. |
|
exclude
regex |
Exclude files by a regular expression. Matches will be removed from the list. |
|
file_date
string |
Filter by last modified dates. The target value can be any date supported by PHP’s strtotime function. |
|
limit
integer |
Limit the total results returned. |
|
offset
integer |
The number of entries the results should by offset by. |
|
sort
string |
Sort the listing by |
Variables
|
file
string |
The relative filename path. |
|---|---|
|
filename
string |
The filename part of the path. eg. |
|
basename
string |
The basename part of the path. eg. |
|
extension
string |
The file extension. |
|
size
string |
The file size in a human readable format. |
|
size_bytes|size_b
integer |
The file size in bytes. |
|
size_kilobytes|size_kb
integer |
The file size in kilobytes. |
|
size_megabytes|size_mb
integer |
The file size in megabytes. |
|
size_gigabytes|size_gb
integer |
The file size in gigabytes. |
|
is_image
boolean |
Whether the file is an image. |
|
last_modified
Carbon |
The last modified date of the file. |