aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/text/template
AgeCommit message (Collapse)Author
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-15text/template/parse: fix doc commentShenghou Ma
Fixes #3529. R=golang-dev, r CC=golang-dev https://golang.org/cl/6037046
2012-04-12text/template: catch unexported fields during parseRob Pike
It's a common error to reference unexported field names in templates, especially for newcomers. This catches the error at parse time rather than execute time so the rare few who check errors will notice right away. These were always an error, so the net behavior is unchanged. Should break no existing code, just identify the error earlier. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6009048
2012-04-12html, exp/html: escape ' and " as ' and ", since IE8 andNigel Tao
below do not support '. This makes package html consistent with package text/template's HTMLEscape function. Fixes #3489. R=rsc, mikesamuel, dsymonds CC=golang-dev https://golang.org/cl/5992071
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-23text/template: fix typo in package commentRobert Griesemer
Fixes #3383. R=iant, bradfitz CC=golang-dev https://golang.org/cl/5891045
2012-03-14text/template: variables do not take argumentsRob Pike
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5821044
2012-03-14text/template: fix a couple of parse bugs around identifiers.Rob Pike
1) Poor error checking in variable declarations admitted $x=2 or even $x%2. 2) Need white space or suitable termination character after identifiers, so $x+2 doesn't parse, in case we want it to mean something one day. Number 2 in particular prevents mistakes that we will have to honor later and so is necessary for Go 1. Fixes #3270. Fixes #3271. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5795073
2012-03-04text/template: one more test caseRob Pike
Missed a case for variadic functions with too few arguments. The code passes, and with the right error, but might as well record the test case. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5732050
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-03-01text/template: add examples that use multiple templatesRob Pike
Fixes #2742. R=golang-dev, peterthrun, adg CC=golang-dev https://golang.org/cl/5699083
2012-02-28text/template: add example showing use of custom functionRob Pike
R=golang-dev, adg CC=golang-dev https://golang.org/cl/5694100
2012-02-28text/template: fix redefinition bugsRob Pike
R=golang-dev, adg CC=golang-dev https://golang.org/cl/5696087
2012-02-19templates: minor edits to the documentationRob Pike
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5677084
2012-02-16godoc: make example code more readable with new comment conventionAndrew Gerrand
go/doc: move Examples to go/ast cmd/go: use go/doc to read examples src/pkg: update examples to use new convention This is to make whole file examples more readable. When presented as a complete function, preceding an Example with its output is confusing. The new convention is to put the expected output in the final comment of the example, preceded by the string "output:" (case insensitive). An idiomatic example looks like this: // This example demonstrates Foo by doing bar and quux. func ExampleFoo() { // example body that does bar and quux // Output: // example output } R=rsc, gri CC=golang-dev https://golang.org/cl/5673053
2012-02-15html/template: add Clone and AddParseTree. Make text/template's CloneNigel Tao
return (*Template, error), not just *Template. Fixes #2757. R=r CC=golang-dev https://golang.org/cl/5665044
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-02-14text/template: drop reference to os.EPERM in the testRob Pike
R=golang-dev, gri CC=golang-dev https://golang.org/cl/5654077
2012-02-11text/template/parse: deep Copy method for nodesRob Pike
This will help html/template copy templates. R=golang-dev, gri, nigeltao, r CC=golang-dev https://golang.org/cl/5653062
2012-02-10template: refer HTML users to html/templateRob Pike
Fixes #2963. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5650051
2012-02-09text/template/parse: fix commentMikio Hara
R=r, rsc CC=golang-dev https://golang.org/cl/5644055
2012-01-30build: remove Make.pkg, Make.toolRuss Cox
Consequently, remove many package Makefiles, and shorten the few that remain. gomake becomes 'go tool make'. Turn off test phases of run.bash that do not work, flagged with $BROKEN. Future CLs will restore these, but this seemed like a big enough CL already. R=golang-dev, r CC=golang-dev https://golang.org/cl/5601057
2012-01-25text/template: add example for TemplateAndrew Gerrand
R=golang-dev, r CC=golang-dev https://golang.org/cl/5564050
2012-01-19text/template/parse: use human error printsRob Pike
The previous version of all the node.String methods printed the parse tree and was useful for developing the parse tree code. Now that that's done, we might as well print the nodes using the standard template syntax. It's much easier to read and makes error reporting look more natural. Helps issue 2644. R=rsc, n13m3y3r CC=golang-dev https://golang.org/cl/5553066
2012-01-17text/template: fix nil error on redefinitionRob Pike
Fixes #2720. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5545072
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-12-05use new strconv APIRuss Cox
All but 3 cases (in gcimporter.go and hixie.go) are automatic conversions using gofix. No attempt is made to use the new Append functions even though there are definitely opportunities. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5447069
2011-12-01template: move the empty check into parse, which needs it when constructingRob Pike
tree sets. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5449062
2011-12-01text/template: replace Add with AddParseTreeRob Pike
Makes it clear we're adding exactly one tree and creating a new template for it. R=rsc CC=golang-dev https://golang.org/cl/5448077
2011-11-28text/template: address a couple of issues for html/templateRob Pike
- allow Lookup to work on uninitialized templates - fix bug in add: can't error after parser is stopped - add Add method for html/template R=adg, rogpeppe, r, rsc CC=golang-dev https://golang.org/cl/5436080
2011-11-26text/template: rename the method Template.Template to Template.LookupRob Pike
Calling it Template makes it clumsy to embed the type, which html/template depends on. R=golang-dev, gri CC=golang-dev https://golang.org/cl/5432079
2011-11-24text/template: fix bug in CloneRob Pike
Cloned template copied the root template incorrectly. Add test of self-consistency. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5436063
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-18template/parse: rename Set to ParseRob Pike
Preamble to the simplification of the template API. Although the signature of Parse (nee Set) changes, it's really an internal function, used only by text/template. R=golang-dev, rsc, gri, r CC=golang-dev https://golang.org/cl/5415052
2011-11-17text/template: refactor set parsingRob Pike
Parse {{define}} blocks during template parsing rather than separately as a set-specific thing. This cleans up set parse significantly, and enables the next step, if we want, to unify the API for templates and sets. Other than an argument change to parse.Parse, which is in effect an internal function and unused by client code, there is no API change and no spec change yet. R=golang-dev, rsc, r CC=golang-dev https://golang.org/cl/5393049
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-08renaming_1: hand-edited files for go 1 renamingRob Pike
This contains the files that required handiwork, mostly Makefiles with updated TARGs, plus the two packages with modified package names. html/template/doc.go needs a separate edit pass. test/fixedbugs/bug358.go is not legal go so gofix fails on it. R=rsc CC=golang-dev https://golang.org/cl/5340050
2011-11-08text/template: make redefinition of a template in a set more consistent.Rob Pike
Also make it agree with the documentation. You get an error, unless you're calling Add explicitly, in which case it panics since that's almost certainly a bug. The discrepancy was caused by a panic that wasn't turned into an error along one path; deleted the offending function for clarity. R=r, rsc CC=golang-dev https://golang.org/cl/5354045
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