SunHowe/string_formatter

How to use separate FormatFunc lists?

Closed this issue · 2 comments

I want to use StringEx in different contexts. I dont want to share functions between contexts
Please, add support for StringEx to use different FormatFunc lists

You can use scriban instead: https://github.com/scriban/scriban

        public void DifferentContextTest()
        {
            var formatter1 = new StringFormatter.StringFormatter();
            formatter1.RegisterFormatFunc("name", () => "name in context1");
            
            var formatter2 = new StringFormatter.StringFormatter();
            formatter2.RegisterFormatFunc("name", () => "name in context2");
            
            Assert.AreEqual(formatter1.Format("{name}"), "name in context1");
            Assert.AreEqual(formatter2.Format("{name}"), "name in context2");
        }