Closed gep13 closed 7 years ago
Like this?
---
Title: {{System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(System.IO.Path.GetFileNameWithoutExtension(Model.ActiveDocument.Filename).Replace('-', ' '))}}
Tags:
-
---
Ok... I made a few more changes to the @Razor hosting part that now allows adding assemblies and namespaces.
This is what you want:
@reference Westwind.Utilities.dll
@using Westwind.Utilities
@{
var file = Path.GetFileNameWithoutExtension(Model.ActiveDocument.Filename);
file = StringUtils.FromCamelCase(file);
file = file.Replace("-"," ");
}---
Title: @file
Timestamp: @DateTime.Now.ToString("MMM dd, yyyy HH:mm")
Tags:
-
---
FWIW, the first two lines will not be necesary any more as I'm adding those as default dependencies.
You'll need to make sure you grab 1.10 of the addin though - update and restart.
@RickStrahl thank you very much! This is perfect!
I modified it slightly:
@{
var file = Path.GetFileNameWithoutExtension(Model.ActiveDocument.Filename);
file = file.Replace("-"," ");
file = StringUtils.ProperCase(file);
}---
Title: @file
Timestamp: @DateTime.Now.ToString("MMM dd, yyyy HH:mm")
Tags:
-
---
@RickStrahl Is it possible to just get the file name without the path and extension?
This is what I currently have in my snippet (based on a file called
this-is-a-test.md
)Which results in the following:
So, quite close to what I am looking for 😄