webtry: Simplify template construction.
text/template and html/template both have a helper function called "Must" that according to the docs in http://golang.org/pkg/text/template/#Must and http://golang.org/pkg/html/template/#Must, wraps a call to a function returning (*Template, error) and panics if the error is non-nil. So we don't need to that ourselves. Which is a good thing and makes code cleaner. BUG=None TEST=None R=jcgregorio@google.com Review URL: https://codereview.chromium.org/642243004
This commit is contained in:
parent
bdc49ae0d4
commit
585a5fc243
@ -146,55 +146,37 @@ func init() {
|
||||
}
|
||||
os.Chdir(cwd)
|
||||
|
||||
codeTemplate, err = template.ParseFiles(filepath.Join(cwd, "templates/template.cpp"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gypTemplate, err = template.ParseFiles(filepath.Join(cwd, "templates/template.gyp"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
indexTemplate, err = htemplate.ParseFiles(
|
||||
codeTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "templates/template.cpp")))
|
||||
gypTemplate = template.Must(template.ParseFiles(filepath.Join(cwd, "templates/template.gyp")))
|
||||
indexTemplate = htemplate.Must(htemplate.ParseFiles(
|
||||
filepath.Join(cwd, "templates/index.html"),
|
||||
filepath.Join(cwd, "templates/titlebar.html"),
|
||||
filepath.Join(cwd, "templates/sidebar.html"),
|
||||
filepath.Join(cwd, "templates/content.html"),
|
||||
filepath.Join(cwd, "templates/headercommon.html"),
|
||||
filepath.Join(cwd, "templates/footercommon.html"),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
iframeTemplate, err = htemplate.ParseFiles(
|
||||
))
|
||||
iframeTemplate = htemplate.Must(htemplate.ParseFiles(
|
||||
filepath.Join(cwd, "templates/iframe.html"),
|
||||
filepath.Join(cwd, "templates/content.html"),
|
||||
filepath.Join(cwd, "templates/headercommon.html"),
|
||||
filepath.Join(cwd, "templates/footercommon.html"),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
recentTemplate, err = htemplate.ParseFiles(
|
||||
))
|
||||
recentTemplate = htemplate.Must(htemplate.ParseFiles(
|
||||
filepath.Join(cwd, "templates/recent.html"),
|
||||
filepath.Join(cwd, "templates/titlebar.html"),
|
||||
filepath.Join(cwd, "templates/sidebar.html"),
|
||||
filepath.Join(cwd, "templates/headercommon.html"),
|
||||
filepath.Join(cwd, "templates/footercommon.html"),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
workspaceTemplate, err = htemplate.ParseFiles(
|
||||
))
|
||||
workspaceTemplate = htemplate.Must(htemplate.ParseFiles(
|
||||
filepath.Join(cwd, "templates/workspace.html"),
|
||||
filepath.Join(cwd, "templates/titlebar.html"),
|
||||
filepath.Join(cwd, "templates/sidebar.html"),
|
||||
filepath.Join(cwd, "templates/content.html"),
|
||||
filepath.Join(cwd, "templates/headercommon.html"),
|
||||
filepath.Join(cwd, "templates/footercommon.html"),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
))
|
||||
|
||||
// The git command returns output of the format:
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user