Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Last active August 3, 2019 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloaj/187c9546130edcf1c611b1e343017286 to your computer and use it in GitHub Desktop.
Save juanpabloaj/187c9546130edcf1c611b1e343017286 to your computer and use it in GitHub Desktop.
gobuffalo/plush example
package main
import (
"fmt"
"time"
"github.com/gobuffalo/plush"
)
func main() {
html := `hello, my name is <%= name %>`
htmlCapitalize := `hello my name is <%= upcase(name) %>`
htmlDate := `<%= now %>: hello, my name is <%= name %>`
ctx := plush.NewContext()
ctx.Set("name", "bob")
ctx.Set("now", time.Now())
rendered, _ := plush.Render(html, ctx)
capitalized, _ := plush.Render(htmlCapitalize, ctx)
withDate, err := plush.Render(htmlDate, ctx)
if err != nil {
fmt.Println(err)
}
fmt.Println(rendered)
fmt.Println(capitalized)
fmt.Println(withDate)
}
@juanpabloaj
Copy link
Author

output

hello, my name is bob
hello my name is BOB
August 03, 2019 19:41:58 -0400: hello, my name is bob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment