]> Cypherpunks repositories - gostls13.git/commit
exp/template/html: New package with a toy template transformation.
authorMike Samuel <mikesamuel@gmail.com>
Fri, 12 Aug 2011 04:34:29 +0000 (14:34 +1000)
committerRob Pike <r@golang.org>
Fri, 12 Aug 2011 04:34:29 +0000 (14:34 +1000)
commit595e9d50344eb9afe878490296b19c5eac1b38b0
treec7b671ae415bcfc93d1f18a65a80af6286e1f7a3
parent1b13131c6bf7f3e26a38f5afbd1aa561cd77e317
exp/template/html: New package with a toy template transformation.

func Reverse(*Template) *Template
returns a template that produces the reverse of the original
for any input.

Changes outside exp/template/html include:
- Adding a getter for a template's FuncMap so that derived templates
  can inherit function definitions.
- Exported one node factory function, newIdentifier.
  Deriving tempaltes requires constructing new nodes, but I didn't
  export all of them because I think shallow copy functions might
  be more useful for this kind of work.
- Bugfix: Template's Name() method ignores the name field so
  template.New("foo") is a nil dereference instead of "foo".

Caveats: Reverse is a toy.  It is not UTF-8 safe, and does not
preserve order of calls to funcs in FuncMap.

For context, see http://groups.google.com/group/golang-nuts/browse_thread/thread/e8bc7c771aae3f20/b1ac41dc6f609b6e?lnk=gst

R=rsc, r, nigeltao, r
CC=golang-dev
https://golang.org/cl/4808089
src/pkg/Makefile
src/pkg/exp/template/html/Makefile [new file with mode: 0644]
src/pkg/exp/template/html/reverse.go [new file with mode: 0644]
src/pkg/exp/template/html/reverse_test.go [new file with mode: 0644]
src/pkg/exp/template/parse.go
src/pkg/exp/template/parse/node.go
src/pkg/exp/template/parse/parse.go