mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
27 lines
477 B
Go
27 lines
477 B
Go
package source
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
)
|
|
|
|
type ByteSource struct {
|
|
Name string
|
|
Content []byte
|
|
}
|
|
|
|
func (b *ByteSource) String() string {
|
|
return fmt.Sprintf("%s %s", b.Name, string(b.Content))
|
|
}
|
|
|
|
type InMemorySource struct {
|
|
ByteSource []ByteSource
|
|
}
|
|
|
|
func (i *InMemorySource) Files() (files []*File) {
|
|
files = make([]*File, len(i.ByteSource))
|
|
for i, fake := range i.ByteSource {
|
|
files[i] = NewFileWithContents(fake.Name, bytes.NewReader(fake.Content))
|
|
}
|
|
return
|
|
}
|