go.talks/pkg/present: add iframe command

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7037047
diff --git a/pkg/present/doc.go b/pkg/present/doc.go
index ebe9f6d..e1544f7 100644
--- a/pkg/present/doc.go
+++ b/pkg/present/doc.go
@@ -53,6 +53,7 @@
 	.code x.go /^func main/,/^}/
 	.play y.go
 	.image image.jpg
+	.iframe http://foo
 	.link http://foo label
 	.html file.html
 
@@ -160,6 +161,11 @@
 
 	.image images/betsy.jpg 100 200
 
+iframe:
+
+The function "iframe" injects iframes (pages inside pages).
+Its syntax is the same as that of image.
+
 html:
 
 The function html includes the contents of the specified file as
diff --git a/pkg/present/iframe.go b/pkg/present/iframe.go
new file mode 100644
index 0000000..b9f0e78
--- /dev/null
+++ b/pkg/present/iframe.go
@@ -0,0 +1,45 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package present
+
+import (
+	"fmt"
+	"strings"
+)
+
+func init() {
+	Register("iframe", parseIframe)
+}
+
+type Iframe struct {
+	URL    string
+	Width  int
+	Height int
+}
+
+func (i Iframe) TemplateName() string { return "iframe" }
+
+func parseIframe(fileName string, lineno int, text string) (Elem, error) {
+	args := strings.Fields(text)
+	i := Iframe{URL: args[1]}
+	a, err := parseArgs(fileName, lineno, args[2:])
+	if err != nil {
+		return nil, err
+	}
+	switch len(a) {
+	case 0:
+		// no size parameters
+	case 2:
+		if v, ok := a[0].(int); ok {
+			i.Height = v
+		}
+		if v, ok := a[1].(int); ok {
+			i.Width = v
+		}
+	default:
+		return nil, fmt.Errorf("incorrect image invocation: %q", text)
+	}
+	return i, nil
+}
diff --git a/present/templates/action.tmpl b/present/templates/action.tmpl
index a880089..657e7db 100644
--- a/present/templates/action.tmpl
+++ b/present/templates/action.tmpl
@@ -36,6 +36,10 @@
   <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}>
 </div>
 {{end}}
+
+{{define "iframe"}}
+<iframe src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}></iframe>
+{{end}}
       
 {{define "link"}}<p class="link"><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>{{end}}