Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading CR/LF is lost after Render() #93

Closed
frederik256 opened this issue Dec 21, 2014 · 2 comments
Closed

Leading CR/LF is lost after Render() #93

frederik256 opened this issue Dec 21, 2014 · 2 comments
Assignees
Milestone

Comments

@frederik256
Copy link

A string starting with a newline will lose the newline in the rendered template.

Repro:

string text = Environment.NewLine + "something invariant";
Template template = new Template(text, '«', '»');            
if (!text.Equals(template.Render())) throw new Exception("Text not invariant.");

This is using "Antlr4.StringTemplate" C# package from nuget, version=4.0.6.9004 (running on Windows)

@sharwell
Copy link
Member

This behavior is certainly correct for a template defined using a .stg file:

SomeTemplate ::= <<
something invariant>>

I need to see if the elimination of the leading newline is part of a StringTemplate group preprocessing step (meaning this is a bug), or part of the template parsing step (meaning this is the expected behavior).

@sharwell
Copy link
Member

📝 This does appear to be a bug. The elimination of the first/last newline should only apply to templates defined in a .stg file.

@sharwell sharwell added this to the 4.0.9 milestone Jul 17, 2016
@sharwell sharwell self-assigned this Jul 17, 2016
sharwell added a commit to sharwell/stringtemplate4 that referenced this issue Jul 17, 2016
@parrt parrt closed this as completed in #154 Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants