예제 #1
0
파일: site.go 프로젝트: 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
}
예제 #2
0
파일: site.go 프로젝트: 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
}