Created
September 23, 2014 07:11
-
-
Save yosssi/70ea023495531ea1a01b to your computer and use it in GitHub Desktop.
20140923-ace-01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = doctype html | |
| html | |
| head | |
| title Ace Sample | |
| body | |
| = yield main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h3 This is an include file! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = content main | |
| h1 Ace Sample | |
| h2 Hello Ace! | |
| = include inc | |
| h3 {{.AA}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "net/http" | |
| "text/template" | |
| "github.com/yosssi/ace" | |
| "github.com/yosssi/gohtml" | |
| ) | |
| func handler(w http.ResponseWriter, r *http.Request) { | |
| tpl, err := ace.Load("base", "inner", nil) | |
| if err != nil { | |
| panic(err) | |
| } | |
| if err := tpl.Execute(w, "test"); err != nil { | |
| bf := new(bytes.Buffer) | |
| tpl.Execute(bf, nil) | |
| fmt.Fprintf(w, "<pre>Error:\n%s\nHTML:\n%s</pre>", err.Error(), template.HTMLEscapeString(gohtml.FormatWithLineNo(bf.String()))) | |
| } | |
| } | |
| func main() { | |
| http.HandleFunc("/", handler) | |
| http.ListenAndServe(":8080", nil) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment