github.com/jasonish/buffalo@v0.8.2-0.20170413145823-bacbdd415f1b/render/html.go (about)

     1  package render
     2  
     3  // HTML renders the named files using the 'text/html'
     4  // content type and the github.com/aymerick/raymond
     5  // package for templating. If more than 1 file is provided
     6  // the second file will be considered a "layout" file
     7  // and the first file will be the "content" file which will
     8  // be placed into the "layout" using "{{yield}}".
     9  func HTML(names ...string) Renderer {
    10  	e := New(Options{})
    11  	return e.HTML(names...)
    12  }
    13  
    14  // HTML renders the named files using the 'text/html'
    15  // content type and the github.com/aymerick/raymond
    16  // package for templating. If more than 1 file is provided
    17  // the second file will be considered a "layout" file
    18  // and the first file will be the "content" file which will
    19  // be placed into the "layout" using "{{yield}}". If no
    20  // second file is provided and an `HTMLLayout` is specified
    21  // in the options, then that layout file will be used
    22  // automatically.
    23  func (e *Engine) HTML(names ...string) Renderer {
    24  	if e.HTMLLayout != "" {
    25  		names = append(names, e.HTMLLayout)
    26  	}
    27  	if len(names) > 2 {
    28  		names = names[:2]
    29  	}
    30  	hr := templateRenderer{
    31  		Engine:      e,
    32  		contentType: "text/html",
    33  		names:       names,
    34  	}
    35  	return hr
    36  }