fields

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SEPARATOR is the separator that defines the split between
	// field keys for repeaters and flexible content.
	SEPARATOR = "|"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldService

type FieldService interface {
	GetField(name string, args ...interface{}) interface{}
	GetFieldObject(name string, args ...interface{}) domain.PostField
	GetFields(args ...interface{}) Fields
	GetLayout(name string, args ...interface{}) domain.Field
	GetLayouts(args ...interface{}) domain.FieldGroups
	GetRepeater(input interface{}, args ...interface{}) Repeater
	GetFlexible(input interface{}, args ...interface{}) Flexible
}

FieldService defines methods for obtaining fields for the front end templates.

type Fields

type Fields map[string]interface{}

Fields defines the map of fields to be returned to the template.

type Flexible

type Flexible []Layout

Flexible represents the collection of layouts used for the flexible content function in templates.

func (Flexible) HasRows

func (f Flexible) HasRows() bool

HasRows

Determines if the Flexible content has any rows.

type Layout

type Layout struct {
	Name      string
	SubFields SubFields
}

Layout represents the collection of subfield's and layout's name.

type Repeater

type Repeater []Row

Repeater represents the collection of rows used for the repeater function in templates.

func (Repeater) HasRows

func (r Repeater) HasRows() bool

HasRows

Determines if the Repeater has any rows.

func (Repeater) Length

func (r Repeater) Length() int

Length

Returns the amount of rows within the repeater.

type Row

type Row domain.PostFields

Row represents the collection of the repeaters containing `sub_fields.

func (Row) First

func (r Row) First() interface{}

First

Returns the first element in the repeater, or nil if the length of the repeater is zero.

func (Row) HasField

func (r Row) HasField(name string) bool

HasField

Returns true if a field exists within the row.

func (Row) Last

func (r Row) Last() interface{}

Last

Returns the last element in the repeater, or nil if the length of the repeater is zero.

func (Row) SubField

func (r Row) SubField(name string) interface{}

SubField

Returns a sub field by key or nil if it wasn't found.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service

Defines the helper for obtaining fields for front end templates.

func NewService

func NewService(d *deps.Deps, p *domain.PostDatum) *Service

NewService

Construct, creates a new slice of post fields and slice of layouts.

func (*Service) GetField

func (s *Service) GetField(name string, args ...interface{}) interface{}

GetField

Returns the value of a specific field. Returns errors.NOTFOUND if the field was not found by the given key.

func (*Service) GetFieldObject

func (s *Service) GetFieldObject(name string, args ...interface{}) domain.PostField

GetFieldObject

Returns the raw object of a specific field. Returns errors.NOTFOUND if the field was not found by the given key.

func (*Service) GetFields

func (s *Service) GetFields(args ...interface{}) Fields

GetFields

Returns all of the fields for the current post, or post ID given.

func (*Service) GetFlexible

func (s *Service) GetFlexible(input interface{}, args ...interface{}) Flexible

GetFlexible

Returns the collection of Layouts from the given key and returns a new Flexible.

Returns errors.INVALID if the field type is not flexible content. Returns errors.INTERNAL if the layouts could not be cast to a string slice.

func (*Service) GetLayout

func (s *Service) GetLayout(name string, args ...interface{}) domain.Field

GetGroup

func (*Service) GetLayouts

func (s *Service) GetLayouts(args ...interface{}) domain.FieldGroups

GetGroups

func (*Service) GetRepeater

func (s *Service) GetRepeater(input interface{}, args ...interface{}) Repeater

GetRepeater

Returns the collection of children from the given key and returns a new Repeater.

Returns errors.NOTFOUND if the field was not found by the given key. Returns errors.INVALID if the field type is not a repeater or the name could not be cast.

type SubFields

type SubFields domain.PostFields

Subfields represents the collection of fields used for templates. It has various functions attached to it making it easier to loop over.

func (SubFields) First

func (s SubFields) First() interface{}

First

Returns the first element in the sub fields, or nil if the length of the sub fields is zero.

func (SubFields) Last

func (s SubFields) Last() interface{}

Last

Returns the last element in the sub fields, or nil if the length of the sub fields is zero.

func (SubFields) SubField

func (s SubFields) SubField(name string) interface{}

SubField

Returns a sub field by key or nil if it wasn't found.

type WalkerFunc

type WalkerFunc func(field domain.PostField)

WalkerFunc defines the function for walking the slice of domain.PostField when being mapped. It send the field back to the calling function for processing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL