aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/text/template/exec.go
AgeCommit message (Collapse)Author
2014-09-08build: move package sources from src/pkg to srcRuss Cox
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.
2014-09-03text/template: 0xef is an integer, not a floating-point value.Rob Pike
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
2014-05-19text/template,html/template: document that partial results may be written on ↵Rob Pike
error Fixes #7445. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/94640043
2014-04-15text/template: say more often that templates are safe for parallel executionRob Pike
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
2014-02-14text/template: don't panic when function call evaluates a nil pointerRob Pike
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
2013-08-27text/template: make the escapers for HTML etc. handle pointers correctlyRob Pike
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
2013-07-23all: be more idiomatic when documenting boolean return values.Rob Pike
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
2013-03-27text/template: fix bug in evaluating a chain starting with a function.Rob Pike
R=golang-dev, alberto.garcia.hierro CC=golang-dev https://golang.org/cl/7861046
2013-03-06text/template: improve error reporting for executing an empty templateRob Pike
Fixes #4522. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7502044
2012-10-03text/template: better error messages during execution,Rob Pike
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
2012-09-24text/template: allow .Field access to parenthesized expressionsRob Pike
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
2012-08-24text/template: allow grouping of pipelines using parenthesesRob Pike
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
2012-08-08text/template: add 'nil' as a keyword in the languageRob Pike
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
2012-05-22text/template: exec should accept interface value as valid.Ugorji Nwoke
Currently, if you pass some data to a template as an interface (e.g. interface{}) and extract that value that value as a parameter for a function, it fails, saying wrong type. This is because it is only looking at the interface type, not the interface content. This CL uses the underlying content as the parameter to the func. Fixes #3642. R=golang-dev, r, r CC=golang-dev https://golang.org/cl/6218052
2012-04-24text/template: improve the error reporting for unexported fields.Rob Pike
Changes suggested by rsc after last CL. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6117044
2012-04-23text/template: detect unexported fields betterRob Pike
Moves the error detection back into execution, where it used to be, and improves the error message. Rolls back most of 6009048, which broke lower-case keys in maps. If it weren't for maps we could detect this at compile time rather than execution time. Fixes #3542. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6098051
2012-04-03text/template: pipelined arg was not typecheckedRob Pike
Without this fix, an erroneous template causes a panic; should be caught safely. The bug did not affect correct templates. Fixes #3267. R=golang-dev, dsymonds, rsc CC=golang-dev https://golang.org/cl/5900065
2012-03-14text/template: variables do not take argumentsRob Pike
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5821044
2012-03-03text/template: clean up function valuesRob Pike
The recent addition of automatic function invocation generated some troublesome ambiguities. Restore the previous behavior and compensate by providing a "call" builtin to make it easy to do what the automatic invocation did, but in a clear and explicit manner. Fixes #3140. At least for now. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/5720065
2012-02-15text/template: evaluate function fieldsRob Pike
Just an oversight they didn't work and easy to address. Fixes #3025. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5656059
2012-01-13template: for range on a map, sort the keys if feasible.Rob Pike
Fixes #2696. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5543055
2012-01-09text/template: handle panic values that are not errors.Rémy Oudompheng
The recover code assumes that the panic() argument was an error, but it is usually a simple string. Fixes #2663. R=golang-dev, r, r, gri CC=golang-dev, remy https://golang.org/cl/5527046
2011-12-20template: better error message for empty templatesRob Pike
New("x").ParseFiles("y") can result in an empty "x" template. Make the message clearer that this is the problem. The error returns from both template packages in this case were confusing. I considered making the method use "x" instead of "y" in this case, but that just made other situations confusing and harder to explain. Fixes #2594. R=golang-dev, rsc, r CC=golang-dev https://golang.org/cl/5498048
2011-12-18text/template: fix handing of nil arguments to functionsGustavo Niemeyer
R=golang-dev, r CC=golang-dev https://golang.org/cl/5494070
2011-11-23text/template: new, simpler APIRob Pike
The Set type is gone. Instead, templates are automatically associated by being parsed together; nested definitions implicitly create associations. Only associated templates can invoke one another. This approach dramatically reduces the breadth of the construction API. For now, html/template is deleted from src/pkg/Makefile, so this can be checked in. Nothing in the tree depends on it. It will be updated next. R=dsymonds, adg, rsc, r, gri, mikesamuel, nigeltao CC=golang-dev https://golang.org/cl/5415060
2011-11-08renaming_3: gofix -r go1pkgrename src/pkg/[m-z]*Rob Pike
R=rsc CC=golang-dev https://golang.org/cl/5345045
2011-11-04template: format error with pointer receiver.David Symonds
This is a continuation of 982d70c6d5d6. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5348042
2011-11-04template: format errorsRuss Cox
R=golang-dev, r CC=golang-dev https://golang.org/cl/5340043
2011-11-03os,text,unicode: renamingsRob Pike
This is Go 1 package renaming CL #4. This one merely moves the source; the import strings will be changed after the next weekly release. This one moves pieces into os, text, and unicode. exec -> os/exec scanner -> text/scanner tabwriter -> text/tabwriter template -> text/template template/parse -> text/template/parse utf16 -> unicode/utf16 utf8 -> unicode/utf8 This should be the last of the source-rearranging CLs. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5331066