data

package
v0.0.0-...-4dafff4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2017 License: MIT Imports: 9 Imported by: 7

Documentation

Overview

Package data contains the definitions for the Soy data types.

Index

Constants

This section is empty.

Variables

View Source
var DefaultStructOptions = StructOptions{
	LowerCamel: true,
	TimeFormat: time.RFC3339,
}

Functions

This section is empty.

Types

type Bool

type Bool bool

func (Bool) Equals

func (v Bool) Equals(other Value) bool

func (Bool) String

func (v Bool) String() string

func (Bool) Truthy

func (v Bool) Truthy() bool

func (Bool) Type

func (v Bool) Type() Type

type Float

type Float float64

func (Float) Equals

func (v Float) Equals(other Value) bool

func (Float) String

func (v Float) String() string

func (Float) Truthy

func (v Float) Truthy() bool

func (Float) Type

func (v Float) Type() Type

type HTML

type HTML string

func (HTML) Equals

func (v HTML) Equals(other Value) bool

func (HTML) String

func (v HTML) String() string

func (HTML) Truthy

func (v HTML) Truthy() bool

func (HTML) Type

func (v HTML) Type() Type

type Int

type Int int64

func (Int) Equals

func (v Int) Equals(other Value) bool

func (Int) String

func (v Int) String() string

func (Int) Truthy

func (v Int) Truthy() bool

func (Int) Type

func (v Int) Type() Type

type List

type List []Value

func (List) Equals

func (v List) Equals(other Value) bool

func (List) Index

func (v List) Index(i int) Value

Index retrieves a value from this list, or Undefined if out of bounds.

func (List) String

func (v List) String() string

func (List) Truthy

func (v List) Truthy() bool

func (List) Type

func (v List) Type() Type

type Map

type Map map[string]Value

func (Map) Equals

func (v Map) Equals(other Value) bool

func (Map) Key

func (v Map) Key(k string) Value

Key retrieves a value under the named key, or Undefined if it doesn't exist.

func (Map) String

func (v Map) String() string

func (Map) Truthy

func (v Map) Truthy() bool

func (Map) Type

func (v Map) Type() Type

type Marshaler

type Marshaler interface {
	MarshalValue() Value
}

Marshaler is the interface implemented by entities that can marshal themselves into a data.Value.

type Null

type Null struct{}

func (Null) Equals

func (v Null) Equals(other Value) bool

func (Null) MarshalJSON

func (v Null) MarshalJSON() ([]byte, error)

func (Null) String

func (v Null) String() string

func (Null) Truthy

func (v Null) Truthy() bool

func (Null) Type

func (v Null) Type() Type

type String

type String string

func (String) Equals

func (v String) Equals(other Value) bool

func (String) String

func (v String) String() string

func (String) Truthy

func (v String) Truthy() bool

func (String) Type

func (v String) Type() Type

type StructOptions

type StructOptions struct {
	LowerCamel bool   // if true, convert field names to lowerCamel.
	TimeFormat string // format string for time.Time. (if empty, use ISO-8601)
}

StructOptions provides flexibility in conversion of structs to soy's data.Map format.

func (StructOptions) Data

func (c StructOptions) Data(obj interface{}) Map

type Type

type Type string

Type represents a Soy data type.

type Undefined

type Undefined struct{}

func (Undefined) Equals

func (v Undefined) Equals(other Value) bool

func (Undefined) MarshalJSON

func (v Undefined) MarshalJSON() ([]byte, error)

func (Undefined) String

func (v Undefined) String() string

func (Undefined) Truthy

func (v Undefined) Truthy() bool

func (Undefined) Type

func (v Undefined) Type() Type

Type ---------

type Value

type Value interface {
	// Truthy returns true according to the Soy definition of truthy and falsy values.
	Truthy() bool

	// String formats this value for display in a template.
	String() string

	// Type returns the Soy type of this object.
	Type() Type

	// Equals returns true if the two values are equal.  Specifically, if:
	// - They are comparable: they have the same Type, or they are Int and Float
	// - (Primitives) They have the same value
	// - (Lists, Maps) They are the same instance
	// Uncomparable types and unequal values return false.
	Equals(other Value) bool
}

Value represents a Soy data value, which may be one of the enumerated types.

func New

func New(value interface{}) Value

New converts the given data into a soy data value, using DefaultStructOptions for structs.

func NewWith

func NewWith(convert StructOptions, value interface{}) Value

NewWith converts the given data value soy data value, using the provided StructOptions for any structs encountered.

Jump to

Keyboard shortcuts

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