logo Buffalo slack logo
Diseños
Frontend

Diseño#

Este documento solo aplica cuando se usa github.com/gobuffalo/buffalo/render.

Consulta github.com/gobuffalo/plush para más detalles sobre el paquete de plantillas.

Usando un diseño estándar#

Es bastante común querer usar el mismo diseño en la mayoria, si no en toda la aplicación. Al crear un nuevo render.Engine the se puede establecer la propiedad HTMLLayout a un archivo que será usado automáticamente por la función render.HTML.

actions/render.go
templates/application.plush.html
templates/hello.plush.html
actions/hello.go
Output
var r *render.Engine

func init() {
  r = render.New(render.Options{
    // ...
    HTMLLayout: "application.plush.html",
    // ...
  })
}

Usando un diseño personalizado#

A veces, en ciertas peticiones, se necesita un diseño diferente. Este diseó alternativo se puede pasar como segundo parámetro al render.HTML.

Los diseños personalizados NO funcionan con render.Auto.
actions/render.go
templates/custom.plush.html
templates/hello.plush.html
actions/hello.go
Output
var r *render.Engine

func init() {
  r = render.New(render.Options{
    // ...
    HTMLLayout: "application.plush.html", // You can realize that render continues using the application.plush.html
    // ...
  })
}