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
Assignees
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 13, 2014

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 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 cznic commented Feb 16, 2014

Comment 2:

Also, http://play.golang.org/p/DJOeuHq7M7 is perhaps what you want.
@rsc
Copy link
Contributor

@rsc rsc commented Mar 4, 2014

Comment 3:

Owner changed to @robpike.

Status changed to Thinking.

@adg
Copy link
Contributor

@adg adg commented Mar 31, 2014

Comment 4:

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

@kmulvey
Copy link

@kmulvey 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
@rsc rsc removed release-none labels Apr 10, 2015
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Apr 30, 2015

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

@robpike robpike closed this in 0422001 May 1, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.