Custom Path Helpers
December 17, 2019 ยท View on GitHub
These helpers provide the ability to parse paths.
- Helpers.Path.GetAbsolutePath
- Helpers.Path.GetDirectory
- Helpers.Path.GetExtension
- Helpers.Path.GetFilename
Helpers.Path.GetAbsolutePath
| Summary | Given path, get just the folder paths |
| Returns | Folder paths |
| Remarks | |
| Parameters | |
| path | Path to pull info from |
| delimiter | Delimiter to parse path with, defaults to / |
Example
Context
{
"a": "/first/second/third/somefile.txt",
"b": "first_second_third_somefile.txt"
}
Usage
<strong>result:</strong>
{{Helpers.Path.GetAbsolutePath a}}
{{Helpers.Path.GetAbsolutePath b "_"}}
{{Helpers.Path.GetAbsolutePath "arinet/HandlebarDocs/blob/master/customHelpers.md"}}
Returns
<strong>result:</strong>
/first/second/third
_first_second_third
/arinet/HandlebarDocs/blob/master
Helpers.Path.GetDirectory
| Summary | Given path, get top level directory name |
| Returns | Top level directory name |
| Remarks | |
| Parameters | |
| path | Path to pull info from |
| delimiter | Delimiter to parse path with, defaults to / |
Example
Context
{
"a": "/first/second/third/somefile.txt",
"b": "first_second_third_somefile.txt"
}
Usage
<strong>result:</strong>
{{Helpers.Path.GetDirectory a}}
{{Helpers.Path.GetDirectory b "_"}}
{{Helpers.Path.GetDirectory "arinet/HandlebarDocs/blob/master/customHelpers.md"}}
Returns
<strong>result:</strong>
third
third
master
Helpers.Path.GetExtension
| Summary | Given path, get file extension |
| Returns | File extension |
| Remarks | |
| Parameters | |
| path | Path to pull info from |
| delimiter | Delimiter to parse path with, defaults to / |
Example
Context
{
"a": "/first/second/third/somefile.txt",
"b": "first_second_third_somefile.txt"
}
Usage
<strong>result:</strong>
{{Helpers.Path.GetExtension a}}
{{Helpers.Path.GetExtension b "_"}}
{{Helpers.Path.GetExtension "arinet/HandlebarDocs/blob/master/customHelpers.md"}}
Returns
<strong>result:</strong>
.txt
.txt
.md
Helpers.Path.GetFilename
| Summary | Given path, get file name |
| Returns | File name |
| Remarks | |
| Parameters | |
| path | Path to pull info from |
| delimiter | Delimiter to parse path with, defaults to / |
Example
Context
{
"a": "/first/second/third/somefile.txt",
"b": "first_second_third_somefile.txt"
}
Usage
<strong>result:</strong>
{{Helpers.Path.GetFilename a}}
{{Helpers.Path.GetFilename b "_"}}
{{Helpers.Path.GetFilename "arinet/HandlebarDocs/blob/master/customHelpers.md"}}
Returns
<strong>result:</strong>
somefile.txt
somefile.txt
customHelpers.md