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

text/template: Raw quote doesn't allow \n #7323

Closed
gopherbot opened this issue Feb 13, 2014 · 6 comments
Closed

text/template: Raw quote doesn't allow \n #7323

gopherbot opened this issue Feb 13, 2014 · 6 comments

Comments

@gopherbot
Copy link

by jeffdh:

Raw quotes within a template cannot include '\n' which seems counter to the golang
syntax that does allow '\n'.

Here's an example:

http://play.golang.org/p/ZDIphkpwDh

What is the expected output?
The parser should allow the raw quote with the included '\n'

What do you see instead?
The parser fails thinking the raw quote is unterminated

Which version are you using?  (run 'go version')
First noticed in go1.2, but I see nothing has changed in tip.
I've attached a patch that addresses the issue and changes the test to match.

Attachments:

  1. text_template_raw_quote.patch (832 bytes)
@cznic
Copy link
Contributor

cznic commented Feb 16, 2014

Comment 1:

The template language is not Go, however the lexical grammar might be similar. More
importantly, the documentation[0] explicitly states that:
""""
Actions may not span newlines, although comments can.
""""
#WAI
  [0]: http://golang.org/pkg/text/template/

@cznic
Copy link
Contributor

cznic commented Feb 16, 2014

Comment 2:

Also, http://play.golang.org/p/DJOeuHq7M7 is perhaps what you want.

@rsc
Copy link
Contributor

rsc commented Mar 4, 2014

Comment 3:

Owner changed to @robpike.

Status changed to Thinking.

@adg
Copy link
Contributor

adg commented Mar 31, 2014

Comment 4:

Labels changed: added release-none, repo-main.

@kmulvey
Copy link

kmulvey commented Dec 31, 2014

I think, it would be useful to have multiline raw. I use swigjs on the frontend which has a very similar syntax and it would be nice to just wrap those blocks to not be processed. For now ive just changed the server's delimiter to work around this.

swig example:
https://gist.github.com/kmulvey/e02ea9fa66d165ec3dc1

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@gopherbot
Copy link
Author

CL https://golang.org/cl/9537 mentions this issue.

@robpike robpike closed this as completed in 0422001 May 1, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants