1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:07:56 -07:00

doc/go1: template packages have changed since r60

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5787049
This commit is contained in:
Rob Pike 2012-03-08 17:15:23 +11:00
parent 2b8a7adde8
commit 1cd272d16a
2 changed files with 84 additions and 20 deletions

View File

@ -1953,6 +1953,38 @@ a cast that must be added by hand; the <code>go</code> <code>fix</code> tool wil
</p>
<h3 id="templates">The template packages</h3>
<p>
The <code>template</code> and <code>exp/template/html</code> packages have moved to
<a href="/pkg/text/template/"><code>text/template</code></a> and
<a href="/pkg/html/template/"><code>html/template</code></a>.
More significant, the interface to these packages has been simplified.
The template language is the same, but the concept of "template set" is gone
and the functions and methods of the packages have changed accordingly,
often by elimination.
</p>
<p>
Instead of sets, a <code>Template</code> object
may contain multiple named template definitions,
in effect constructing
name spaces for template invocation.
A template can invoke any other template associated with it, but only those
templates associated with it.
The simplest way to associate templates is to parse them together, something
made easier with the new structure of the packages.
</p>
<p>
<em>Updating</em>:
The imports will be updated by fix tool.
Single-template uses will be otherwise be largely unaffected.
Code that uses multiple templates in concert will need to be updated by hand.
The <a href="/pkg/text/template/#examples">examples</a> in
the documentation for <code>text/template</code> can provide guidance.
</p>
<h3 id="testing">The testing package</h3>
<p>

View File

@ -1838,6 +1838,38 @@ a cast that must be added by hand; the <code>go</code> <code>fix</code> tool wil
</p>
<h3 id="templates">The template packages</h3>
<p>
The <code>template</code> and <code>exp/template/html</code> packages have moved to
<a href="/pkg/text/template/"><code>text/template</code></a> and
<a href="/pkg/html/template/"><code>html/template</code></a>.
More significant, the interface to these packages has been simplified.
The template language is the same, but the concept of "template set" is gone
and the functions and methods of the packages have changed accordingly,
often by elimination.
</p>
<p>
Instead of sets, a <code>Template</code> object
may contain multiple named template definitions,
in effect constructing
name spaces for template invocation.
A template can invoke any other template associated with it, but only those
templates associated with it.
The simplest way to associate templates is to parse them together, something
made easier with the new structure of the packages.
</p>
<p>
<em>Updating</em>:
The imports will be updated by fix tool.
Single-template uses will be otherwise be largely unaffected.
Code that uses multiple templates in concert will need to be updated by hand.
The <a href="/pkg/text/template/#examples">examples</a> in
the documentation for <code>text/template</code> can provide guidance.
</p>
<h3 id="testing">The testing package</h3>
<p>