Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Gregory LEOCADIE
@gleocadie
hello, I was wondering: should I use
https://www.nuget.org/packages/Antlr4.StringTemplate/ or https://www.nuget.org/packages/StringTemplate4/ ?
Is there any differences ? (except that the first one does not pull the dependency to Antlr3.Runtime)
Sam Harwell
@sharwell
The latter is correct. I've been meaning to unlist the former (will do so now)
Gregory LEOCADIE
@gleocadie
Cool thx for the answer.
Jericho
@Jericho
I'm new to StringTemplate and trying to configure a simple template but I get an exception which I believe is due to the delimeters
The exception I get, unfortunately, is not very helpful:
Exception of type 'Antlr4.StringTemplate.Compiler.TemplateException' was thrown.
My code is:
var st = new Template("Dear [firstname]", '[', ']');
st.Add("firstname", "Bob");
var result = st.Render();
In case it can be useful, the stack trace is:
   at Antlr4.StringTemplate.Compiler.TemplateCompiler.ReportMessageAndThrowTemplateException(ITokenStream tokens, IToken templateToken, Parser parser, RecognitionException re)
   at Antlr4.StringTemplate.Compiler.TemplateCompiler.Compile(String srcName, String name, List`1 args, String template, IToken templateToken)
   at Antlr4.StringTemplate.Template..ctor(TemplateGroup group, String template)
Sam Harwell
@sharwell
I believe the problem is an inability to use ] as the closing delimiter
You could test this by using $ instead of ], but leaving the start delimiter as [
Jericho
@Jericho
@sharwell yes that's it. Replacing the closing square bracket with another delimiter gets rid of the exception. Should I opene an issue on github to report this problem?
Sam Harwell
@sharwell
Sure, but just so you know I don't think it's likely for this one to change
Just a better doc and/or message
Jericho
@Jericho
why is it not likely to change?
It would be unfortunate because I don't control the template syntax so I have to find a solution that accepts square brackets
Sam Harwell
@sharwell
Two reasons:
  1. It's not unknown that there are some characters that can't currently be used as one delimiter or the other (even though the documentation and handling for this case is admittedly terrible)
  2. This library is mostly in maintenance mode (critical bug fixes only), where I have limited to work on it and if I break something then many people could feel the pain of breaking
Over the years there are enough things I would like to see improved that a v5 is not out of the question
Jericho
@Jericho
I see.
Sam Harwell
@sharwell
A big one is making it so parts like the template lexer could be replaced without rebuilding the library.
Jericho
@Jericho
I'll poke around stringtemplate source and see if I can figure out the issue. Maybe submit a PR (which you can choose to ignore if you feel it may break something else)
Chrizzly
@Chris2011
Great to see discussion about the C# lexer :)
I really need it for my plugin
ptandukar
@ptandukar

I have get JSON from a third party service as below:
{
"skills": {
"2": {
"localizedName": "Microsoft Office(v2)"
},
"3": {
"localizedName": "Microsoft Excel(v2)xy"
}
}
}

skills is array type. It contains skill list.
The property "2" and "3" could be dynamic - it could be any number.
So, how to create template for this JSON?