Commit 1ddedbae authored by Rob Pike's avatar Rob Pike

tmpltohtml: put a DO NOT EDIT mark automatically in the output

R=r, rsc, r
CC=golang-dev
https://golang.org/cl/5469045
parent 0397b28a
<!-- Effective Go -->
<!--
DO NOT EDIT: created by
tmpltohtml effective_go.tmpl
-->
<h2 id="introduction">Introduction</h2>
......
<!-- Effective Go -->
{{donotedit}}
<h2 id="introduction">Introduction</h2>
......
<!-- A Tutorial for the Go Programming Language -->
<!--
DO NOT EDIT: created by
tmpltohtml go_tutorial.tmpl
-->
<h2>Introduction</h2>
<p>
This document is a tutorial introduction to the basics of the Go programming
......
<!-- A Tutorial for the Go Programming Language -->
{{donotedit}}
<h2>Introduction</h2>
<p>
This document is a tutorial introduction to the basics of the Go programming
......
......@@ -35,6 +35,11 @@ func Usage() {
os.Exit(2)
}
var templateFuncs = template.FuncMap{
"code": code,
"donotedit": donotedit,
}
func main() {
flag.Usage = Usage
flag.Parse()
......@@ -44,7 +49,7 @@ func main() {
// Read and parse the input.
name := flag.Args()[0]
tmpl := template.New(name).Funcs(template.FuncMap{"code": code})
tmpl := template.New(name).Funcs(templateFuncs)
if _, err := tmpl.ParseFiles(name); err != nil {
log.Fatal(err)
}
......@@ -80,6 +85,11 @@ func format(arg interface{}) string {
return ""
}
func donotedit() string {
// No editing please.
return fmt.Sprintf("<!--\n DO NOT EDIT: created by\n tmpltohtml %s\n-->\n", flag.Args()[0])
}
func code(file string, arg ...interface{}) (string, error) {
text := contents(file)
var command string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment