| Age | Commit message (Collapse) | Author |
|
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
|
|
The discriminator in the execution engine was stupid.
Add a test to the parse package too. The problem wasn't there
but the particular case ('e' in a hex integer) was not covered.
Fixes #8622.
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/133530043
|
|
Needless except that the api tool complains. We could fix that issue instead.
TBR=bradfitz
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/133290043
|
|
ErrorContext now has all the information it needs from the Node,
rather than depending on the template that contains it. This makes
it easier for html/template to generate correct locations in its
error messages.
Updated html/template to use this ability where it is easy, which is
not everywhere, but more work can probably push it through.
Fixes #8577.
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/130620043
|
|
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/123390043
|
|
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/105300044
|
|
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/108030044
|
|
error
Fixes #7445.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/94640043
|
|
It was said already but apparently not enough times.
Fixes #6985.
LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/86300043
|
|
Currently Scan ignores an error returned from source if the number
of bytes source has read is 0.
Fixes #7594.
LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/78120043
|
|
Catch the error instead and return it to the user. Before this fix,
the template package panicked. Now you get:
template: bug11:1:14: executing "bug11" at <.PS>: dereference of nil pointer of type *string
Extended example at http://play.golang.org/p/uP6pCW3qKT
Fixes #7333.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/64150043
|
|
Fixes #7117.
LGTM=gri
R=golang-codereviews, gobot, gri
CC=golang-codereviews
https://golang.org/cl/53310044
|
|
Use the smaller read-only bytes.NewReader/strings.NewReader instead
of a bytes.Buffer when possible.
LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/54660045
|
|
Fixes #7032.
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/43960045
|
|
Changes generated by:
gofmt -w -r 'make(a, b)[0:0] -> make(a, 0, b)' src/pkg
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/24820045
|
|
The root cause of the panic reported in https://code.google.com/p/go/issues/detail?id=5980
is that parse's Tree.Text wasn't being copied during the clone.
Fix this by adding and using a Copy method for parse.Tree.
Fixes #5980.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12420044
|
|
right delimiters
It's too late to change this behavior: it breaks templates with minimized JavaScript.
Makes me sad because this common error can never be caught: "{foo}}".
Three cheers for compatibility.
(Leave in a fix to a broken test.)
R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13689043
|
|
It was simply a missing error case: when scanning plain text
outside of an action, a right delimiter should be an error.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13468045
|
|
Based on an old suggestion by rsc, it compares the second
and following arguments to the first.
Unfortunately the code cannot be as pretty as rsc's original
because it doesn't require identical types.
R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/13509046
|
|
The method is simple: the parser just parses
{{if A}}a{{else if B}}b{{end}}
to the same tree that would be produced by
{{if A}}a{{else}}{{if B}}b{{end}}{{end}}
Thus no changes are required in text/template itself
or in html/template, only in text/template/parse.
Fixes #6085
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13327043
|
|
Apply the same rules for argument evaluation and indirection that are
used by the regular evaluator.
Fixes #5802
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13257043
|
|
Add eq, lt, etc. to allow one to do simple comparisons.
It's basic types only (booleans, integers, unsigned integers,
floats, complex, string) because that's easy, easy to define,
and covers the great majority of useful cases, while leaving
open the possibility of a more sweeping definition later.
{{if eq .X .Y}}X and Y are equal{{else}}X and Y are unequal{{end}}
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13091045
|
|
The call builtin unconditionally tries to convert a second return value from a function to the error type. This fails in case nil is returned, effectively making call useless for functions returning two values.
This CL adds a nil check for the second return value, and adds a test.
Note that for regular function and method calls the nil error case is handled correctly and is verified by a test.
R=r
CC=golang-dev
https://golang.org/cl/12804043
|
|
By separating finding the end of the comment from the end of the action,
we can diagnose malformed comments better.
Also tweak the documentation to make the comment syntax clearer.
Fixes #6022.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12570044
|
|
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12396043
|
|
This means that printing a Node will produce output that can be used as valid input.
It won't be exactly the same - some spacing may be different - but it will mean the same.
Fixes #4593.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12006047
|
|
Was stupidly float64; should be complex128.
The tests still pass.
Fixes #5649.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12107044
|
|
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.
Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.
These were edited by hand. A few were cleaned up in other ways.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11699043
|
|
R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/9086043
|
|
R=golang-dev, alberto.garcia.hierro
CC=golang-dev
https://golang.org/cl/7861046
|
|
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7877045
|
|
For better printing, I recently changed Name to return "<unnamed>" for templates
with empty names, but this causes trouble for the many packages that used "" as
the template name, so restore the old behavior.
It's usually printed as a quoted string anyway, so it should be fine.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7577044
|
|
Fixes #4522.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7502044
|
|
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7431054
|
|
so that the user don't need to decipher something like this:
template: main:1: expected %!s(parse.itemType=14) in end; got "|"
now they get this:
template: main:1: unexpected "|" in end
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7128054
|
|
Fixes #4640.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7082044
|
|
Remove trailing whitespace in comments.
No other changes.
R=r
CC=golang-dev
https://golang.org/cl/6815053
|
|
Fixes #3872.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6612060
|
|
Protects the package a little against undesirable clients.
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6624054
|
|
They now show the correct name, the byte offset on the line, and context for the failed evaluation.
Before:
template: three:7: error calling index: index out of range: 5
After:
template: top:7:20: executing "three" at <index "hi" $>: error calling index: index out of range: 5
Here top is the template that was parsed to create the set, and the error appears with the action
starting at byte 20 of line 7 of "top", inside the template called "three", evaluating the expression
<index "hi" $>.
Also fix a bug in index: it didn't work on strings. Ouch.
Also fix bug in error for index: was showing type of index not slice.
The real previous error was:
template: three:7: error calling index: can't index item of type int
The html/template package's errors can be improved by building on this;
I'll do that in a separate pass.
Extends the API for text/template/parse but only by addition of a field and method. The
old API still works.
Fixes #3188.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6576058
|
|
R=r, minux.ma
CC=gobot, golang-dev
https://golang.org/cl/6506120
|
|
Change the grammar so that field access is a proper operator.
This introduces a new node, ChainNode, into the public (but
actually internal) API of text/template/parse. For
compatibility, we only use the new node type for the specific
construct, which was not parseable before. Therefore this
should be backward-compatible.
Before, .X.Y was a token in the lexer; this CL breaks it out
into .Y applied to .X. But for compatibility we mush them
back together before delivering. One day we might remove
that hack; it's the simple TODO in parse.go/operand.
This change also provides grammatical distinction between
f
and
(f)
which might permit function values later, but not now.
Fixes #3999.
R=golang-dev, dsymonds, gri, rsc, mikesamuel
CC=golang-dev
https://golang.org/cl/6494119
|
|
Give the right name for errors, and add a test to check we're
getting the errors we expect.
Also fix an ordering bug (calling add after stopParse) that
caused a nil indirection rather than a helpful error.
Fixes #3280.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6520043
|
|
R=r
CC=golang-dev
https://golang.org/cl/6493097
|
|
Other than catching an error case that was missed before, this
CL introduces no changes to the template language or API.
For simplicity, templates use spaces as argument separators.
This means that spaces are significant: .x .y is not the same as .x.y.
In the existing code, these cases are discriminated by the lexer,
but that means for instance that (a b).x cannot be distinguished
from (a b) .x, which is lousy. Although that syntax is not
supported yet, we want to support it and this CL is a necessary
step.
This CL emits a "space" token (actually a run of spaces) from
the lexer so the parser can discriminate these cases. It therefore
fixes a couple of undisclosed bugs ("hi".x is now an error) but
doesn't otherwise change the language. Later CLs will amend
the grammar to make .X a proper operator.
There is one unpleasantness: With space a token, three-token
lookahead is now required when parsing variable declarations
to discriminate them from plain variable references. Otherwise
the change isn't bad.
The CL also moves the debugging print code out of the lexer
into the test, which is the only place it's needed or useful.
Step towards resolving issue 3999.
It still remains to move field chaining out of the lexer
and into the parser and make field access an operator.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6492054
|
|
This shouldn't be an error (see issue 3999), but until it's handled
correctly, treat it as one to avoid confusion. Without this CL,
(A).X parses as two arguments.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6473059
|
|
Based on work by Russ Cox. From his CL:
This is generally useful but especially helpful when trying
to use the built-in boolean operators. It lets you write:
{{if not (f 1)}} foo {{end}}
{{if and (f 1) (g 2)}} bar {{end}}
{{if or (f 1) (g 2)}} quux {{end}}
instead of
{{if f 1 | not}} foo {{end}}
{{if f 1}}{{if g 2}} bar {{end}}{{end}}
{{$do := 0}}{{if f 1}}{{$do := 1}}{{else if g 2}}{{$do := 1}}{{end}}{{if $do}} quux {{end}}
The result can be a bit LISPy but the benefit in expressiveness and readability
for such a small change justifies it.
I believe no changes are required to html/template.
Fixes #3276.
R=golang-dev, adg, rogpeppe, minux.ma
CC=golang-dev
https://golang.org/cl/6482056
|
|
R=r
CC=golang-dev
https://golang.org/cl/6450136
|
|
Incorrect syntax for comment was erroneously accepted.
Fixes #3919.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6453105
|
|
The keyword reprents an untyped nil and is useful for
passing nil values to methods and functions. The
nil will be promoted to the appropriate type when
used; if a type cannot be assigned, an error results.
R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/6459056
|