Exemplo n.º 1
0
Arquivo: site.go Projeto: jaden/hugo
func (s *Site) renderXML(name string, d interface{}, layouts ...string) (io.Reader, error) {
	renderBuffer := s.NewXMLBuffer()
	err := s.render(name, d, renderBuffer, layouts...)

	var outBuffer = new(bytes.Buffer)

	absURLInXML, err := transform.AbsURLInXML(viper.GetString("BaseUrl"))
	if err != nil {
		return nil, err
	}

	transformer := transform.NewChain(absURLInXML...)
	transformer.Apply(outBuffer, renderBuffer)
	return outBuffer, err
}
Exemplo n.º 2
0
Arquivo: site.go Projeto: dunn/hugo
func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layouts ...string) error {
	renderBuffer := bp.GetBuffer()
	defer bp.PutBuffer(renderBuffer)
	renderBuffer.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n")

	err := s.render(name, d, renderBuffer, layouts...)

	absURLInXML, err := transform.AbsURLInXML(viper.GetString("BaseUrl"))
	if err != nil {
		return err
	}

	outBuffer := bp.GetBuffer()
	defer bp.PutBuffer(outBuffer)

	transformer := transform.NewChain(absURLInXML...)
	transformer.Apply(outBuffer, renderBuffer)

	if err == nil {
		err = s.WriteDestFile(dest, outBuffer)
	}

	return err
}