-
Hi! Thanks for reporting this bug! Please fill in the relevant information from this template so that we can help you best. Smart.Format version:
using SmartFormat;
using SmartFormat.Extensions;
var formatter = Smart.CreateDefaultSmartFormat(); // https://github.com/axuno/SmartFormat/wiki/Templates-_-TemplateFormatter
var templates = new TemplateFormatter();
formatter.AddExtensions(templates);
templates.Register("SomeTemplate", "The template content");
formatter.Format("{0:t(SomeTemplate)}:"); // This line throws.
Our actual use case is for sms templates and looks more like this: var filePaths = Directory.GetFiles(path);
foreach (string filePath in filePaths)
{
string fileName = Path.GetFileNameWithoutExtension(filePath);
string fileText = await File.ReadAllTextAsync(filePath);
templates.Register(fileName, fileText);
} and I found some smses don't need a model. |
Beta Was this translation helpful? Give feedback.
Answered by
axunonb
Nov 19, 2024
Replies: 1 comment 1 reply
-
The numbered or named placeholder selector must be omitted, because there is none (in your case, var formatter = Smart.CreateDefaultSmartFormat();
var templates = new TemplateFormatter();
formatter.AddExtensions(templates);
templates.Register("SomeTemplate", "The template content");
var result = formatter.Format("{:t(SomeTemplate)}");
// result: "The template content" |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mariusz96
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The numbered or named placeholder selector must be omitted, because there is none (in your case,
{0:t
should read{:t
: