EN IT
Open2b version 7.8

Data types

This page documents all data types and their methods used for variables and global functions.

Scriggo data types

For Scriggo's basic data types, see the documentation on data types in Scriggo.

Data type index

type AlignedImage

The AlignedImage type represents an image aligned left, center, or right.

type AlignedImage struct {

    // Alignment, can be "left", "center" or "right".
    Align string

    // Image.
    Image

}

A value of type AlignedImage can be displayed directly in HTML:

{{ image }}

because the HTML method can be called on a value of type AlignedImage.

HTML

func (image AlignedImage) HTML() html

HTML returns the image in a format suitable for display in an HTML page.

IsZero

func (image AlignedImage) IsZero() bool

IsZero returns true if the image is not present.

type AncestorItem

The AncestorItem type represents an ancestor item.

It contains only unexported fields, but a value of this type can be displayed directly in HTML:

{{ item }}

because the HTML method can be called on a value of type AncestorItem.

HTML

func (item AncestorItem) HTML() html

HTML returns the ancestor item in a format suitable for display in an HTML page.

type AppliedFilter

The AppliedFilter type represents an applied filter.

It contains only unexported fields, but a value of this type can be displayed directly in HTML:

{{ filter }}

because the HTML method can be called on a value of type AppliedFilter.

HTML

func (filter AppliedFilter) HTML() html

HTML returns the applied filter in a format suitable for display in an HTML page.

type Attribute

The Attribute type represents a product attribute.

type Attribute struct {

    // Identifier.
    ID int

    // Name.
    Name string

    // Values.
    Values []AttributeValue

}

type AttributeValue

The AttributeValue type represents a value of an attribute.

type AttributeValue struct {

    // Description.
    Description string

    // Icon.
    Icon AttributeValueIcon

    // Identifier.
    ID int

    // Name.
    Name AttributeValueName

    // URL.
    URL string

}

type AttributeValueIcon

The AttributeValueIcon type represents the icon of an attribute value. It can be a color or an image.

type AttributeValueIcon struct {

    // Color in hexadecimal format.
    Color string

    // Image.
    Image Image

}

A value of type AttributeValueIcon can be displayed directly in HTML:

{{ icon }}

because the HTML method can be called on a value of type AttributeValueIcon.

HTML

func (icon AttributeValueIcon) HTML() html

HTML returns the icon in a format suitable for display in an HTML page.

type AttributeValueName

The AttributeValueName type represents the name of an attribute value.

type AttributeValueName struct {

    // Name.
    Value string

}

A value of type AttributeValueName can be displayed directly in HTML:

{{ name }}

because the HTML method can be called on a value of type AttributeValueName.

HTML

func (name AttributeValueName) HTML() html

HTML returns the name in a format suitable for display in an HTML page.

The Banner type represents a single site banner.

type Banner struct {

    // Images.
    Images []BannerImage

    // Location name.
    Name string

}

type BannerImage

The BannerImage type represents a single image of a banner.

type BannerImage struct {

    // Image
    Image

}

A value of type BannerImage can be displayed directly in HTML:

{{ bannerImage }}

because the HTML method can be called on a value of type BannerImage.

HTML

func (image BannerImage) HTML() html

HTML returns the image in a format suitable for display in an HTML page.

type Banners

The Banners type represents the site banners. Its fields are the names of the banner locations. You can see the location names in the Template Editor under Banners by clicking show locations.

type Banners struct {

    // The fields of Banners are the names of the site banner locations.
    // The name "SlideShow" below is just an example.
    SlideShow Banner

}

Example

For example, if the locations are named "Top" and "Footer", Banners is defined like this:

type Banners struct {

    // Banners at the top.
    Top Banner

    // Banners at the bottom of the page.
    Footer Banner

}

and you can display the banners through the banners variable as documented below.

type BlogPost

The BlogPost type represents a blog post.

type BlogPost struct {

    // Author.
    Author string

    // Publication date.
    Date Time

    // Large image.
    LargeImage LinkedImage

    // Small image.
    SmallImage LinkedImage

    // Summary.
    Summary html

    // Title.
    Title LinkedText

}

type BlogTag

The BlogTag type represents a blog tag.

type BlogTag struct {

    // Tag identifier.
    ID int

    // Link to the tag page.
    Name LinkedText

}

A value of type BlogTag can be displayed directly in HTML:

{{ tag }}

because the HTML method can be called on a value of type BlogTag.

HTML

func (tag BlogTag) HTML() html

HTML returns the tag in a format suitable for display in an HTML page.

The Breadcrumb type represents a currently applied filter shown as a breadcrumb. Clicking a filter applies only that filter and its predecessors.

If you filter by keywords and new arrivals, those two will also appear as filters in the breadcrumb.

type Breadcrumb struct {

    // Identifier of the department, producer, or attribute value.
    // If the applied filter is not by department, producer, or attribute, the value is zero.
    // This field is available only in version 7.1 and later.
    ID int

    // Indicates whether the filter is by attribute.
    IsByAttribute bool
    
    // Indicates whether the filter is by departments.
    IsByDepartment bool
    
    // Indicates whether the filter is by keywords.
    IsByKeywords bool
    
    // Indicates whether the filter is by new-arrival products.
    IsByNewrelease bool
    
    // Indicates whether the filter is by price.
    IsByPrice bool
    
    // Indicates whether the filter is by producers.
    IsByProducer bool

    // Name of the applied filter.
    Item html

    // Position starting from 1. Used, for example, for microdata.
    Position int

}

type CartItem

The CartItem type represents an item in the cart.

type CartItem struct {

    // Button to remove the item from the cart.
    ButtonRemove html

    // Button to update the cart after changing the quantity.
    ButtonUpdate html

    // Final departments where the product appears.
    Departments []int

    // Product short description.
    Description html

    // Discount compared to list price. It is zero if Rows is not empty.
    Discount Discount

    // Product image.
    Image LinkedImage

    // Suggestion to the customer about the kind of requests they can make
    // about the product.
    InfoForRequests string

    // Indicates whether it is pre-order.
    IsPreOrder bool

    // List price. It is zero if Rows is not empty.
    ListPrice Price

    // Item name.
    Name html

    // Tax percentage.
    PercentTax Decimal

    // Price. It is zero if Rows is not empty.
    Price Price

    // Quantity pricing. It is empty if Rows is not empty.
    Prices []PriceTier

    // Producer.
    Producer html

    // Producer identifier. If the product has no associated producer,
    // this field is 0.
    ProducerID int

    // Product identifier.
    ProductID int

    // Promotions applied to the item. It is empty if Rows is not empty.
    Promotions []CartItemPromotion

    // Total quantity.
    Quantity Decimal

    // Form the customer can fill out with specific requests
    // about the product.
    Requests html

    // Content of the specific requests
    // about the product.
    RequestsContent string

    // Rows associated with the item.
    Rows []CartItemRow

    // Warehouse code.
    SKU string

    // Indicates whether it must be quoted or can be ordered.
    ToQuote bool

    // Total price.
    TotalPrice Price

    // Availability warning message.
    Warning html

    // Weight.
    Weight Decimal

}

type CartItemRow

The CartItemRow type represents a cart row.

type CartItemRow struct {

    // Discount compared to list price.
    Discount Discount

    // List price.
    ListPrice Price

    // Price.
    Price Price

    // Promotions applied to the row.
    Promotions []CartItemPromotion
    
    // Quantity.
    Quantity Decimal

    // Total price.
    TotalPrice Price

}

type CartPaymentMethod

The CartPaymentMethod type represents a cart payment method.

type CartPaymentMethod struct {

    // Cost.
    Cost Price

    // Identifier.
    ID int

    // Indicates whether this is the payment method set on the cart.
    IsCurrent bool

    // Name.
    Name string

}

type CartItemPromotion

The CartItemPromotion type represents a promotion applied to the row.

type CartItemPromotion struct {

    // Promotion identifier.
    ID int

    // Promotion name.
    Name string

}

type CartShippingMethod

The CartShippingMethod type represents a cart shipping method.

type CartShippingMethod struct {

    // Cost.
    Cost Price

    // Identifier.
    ID int

    // Indicates whether this is the shipping method set on the cart.
    IsCurrent bool

    // Name.
    Name string

}

CanShipToCustomerAddress

func (method CartShippingMethod) CanShipToCustomerAddress() bool

CanShipToCustomerAddress indicates whether the shipping method can be used to ship to the customer address. It returns false if the customer is not logged in.

type CheckoutCart

The CheckoutCart type represents the cart during checkout.

type CheckoutCart struct {

    // Discount coupon currently applied to the cart.
    CurrentCoupon string

    // Percentage or fixed discount on the order.
    Discount Discount

    // Discounts applied to the total cart cost.
    Discounts []Discount

    // Product items being ordered. Same as on the
    // cart.html page.
    Items []CartItem

    // Payment method.
    Payment html

    // Payment cost, for example due to a fee or cash on delivery.
    PaymentCost Price

    // Total cost before applying any discount.
    PrediscountSubtotal Price

    // Shipping method.
    Shipping html

    // Shipping cost.
    ShippingCost Price

    // Subtotal.
    Subtotal Price

    // Total tax amount.
    TaxAmount Decimal

    // Indicates whether this is a quote.
    ToQuote bool

    // Total.
    Total Price

    // Total weight.
    Weight Decimal

}

type ChildDepartment

The ChildDepartment type represents the child department of a given department.

type ChildDepartment struct {

    // Identifier.
    ID int

    // Small image.
    Image LinkedImage

    // Name.         
    Name LinkedText

}

type Collection

The Collection type represents an additional collection.

type Collection struct {

    // Description.
    Description html

    // Identifier.
    ID int

    // Large image.
    LargeImage Image

    // Small image.
    SmallImage Image

    // Short description.
    Summary html

    // Title.
    Title string

    // Page URL in the current language.
    URL string

}

type CreditCard

The CreditCard type contains fields to enable credit card payments.

type CreditCard struct {

    // CVC security code.
    CVC html

    // Error messages.
    Errors html

    // Expiration date.
    Expiry html

    // Name on the card.
    Name html

    // Number.
    Number html

}

Example

If method is a payment method, on the checkout-methods.html page that supports credit card payments, the following code shows the payment form:

{% if cc, ok := method.Pay.(CreditCard); ok  %}
    <div>{{ cc.Number }}</div>
    <div>{{ cc.Expiry }}</div>
    <div>{{ cc.CVC }}</div>
    <div>{{ cc.Name }}</div>
    {{ cc.Errors }}
{% end if %}

type Currency

The Currency type represents a site currency.

type Currency struct {

    // ISO code, for example "EUR".
    Code string

    // Name, for example "Euro".
    Name string

    // Symbol, for example "€".
    Symbol string

}

type Currencies

The Currencies type represents the site currencies.

type Currencies []Currency

You can access individual currencies:

<ul>
  {% for currency in currencies %}
  <li data-design-currency="{{ currency.Code }}">{{ currency.Name }}</li>
  {% end %}
</ul>

In this example, the data-design-currency attribute is used with the value set to a currency code. Open2b automatically applies the exchange rate to all prices on the page when you click the element with the data-design-currency attribute.

Alternatively, the currencies variable can be displayed directly in HTML:

{{ currencies }}

because the HTML method can be called on a value of type Currencies.

The variable will be displayed as a select element and selecting a currency will apply the exchange rate to all prices on the page.

HTML

func (currencies Currencies) HTML() html

HTML returns the HTML code of a select that shows the site currencies. It returns an empty string if the site has only one currency.

IsTrue

func (currencies Currencies) IsTrue() bool

IsTrue returns true if the site has multiple currencies.

type css

The css type represents CSS code.

type css string

A string value is escaped before being rendered in a CSS context. For example:

{% var s = `body { background-color: #FFF; }` %}
{{ s }}

is rendered as:

"body \7b  background-color\3a  #FFF\3b  \7d "

Whereas a css value is not escaped in a CSS context. For example:

{% var s = css(`body { background-color: #FFF; }`) %}
{{ s }}

is rendered as:

body { background-color: #FFF; }

Conversion from string to css

In the previous example the expression css(`body { background-color: #FFF; }`) was used; it looks like a function call, but since css is a type, it is actually a type conversion. body { background-color: #FFF; } is a string that is converted to type css.

Scriggo follows Go’s type conversions. However, for css the conversion is allowed only for string literals. For example:

{{ css(`body { background-color: #FFF; }`) }} {# ok #}
{{ css(myCSS) }} {# error: myCSS is not a literal but a variable #}

type Decimal

The Decimal type represents a decimal number.

It has no accessible fields, but a Decimal value can be displayed directly in HTML:

{{ value }}

because the HTML method can be called on a value of type Decimal.

Add

func (d Decimal) Add(d2 Decimal) Decimal

Add returns the sum d + d2.

Cmp

func (d Decimal) Cmp(d2 Decimal) int

Cmp compares d and d2 and returns:

Div

func (d Decimal) Div(d2 Decimal) Decimal

Div returns the division d / d2. It panics if d2 is 0.

Equal

func (d Decimal) Equal(d2 Decimal) bool

Equal indicates whether d == d2 as decimal numbers.

Float64

func (d Decimal) Float64() float64

Float64 returns the closest float64 value to d. It can return +Inf or -Inf.

HTML

func (d Decimal) HTML() html

HTML returns the decimal number in a format suitable for display in an HTML page. The locale is that of the currently rendered page.

IsNegative

func (d Decimal) IsNegative() bool

IsNegative indicates whether d < 0.

IsPositive

func (d Decimal) IsPositive() bool

IsPositive indicates whether d > 0.

IsZero

func (d Decimal) IsZero() bool

IsZero indicates whether d == 0.

JS

func (d Decimal) JS() string

JS returns the representation of d as a JavaScript number. It allows using a Decimal value in JavaScript code.

Example

If the price variable has type Decimal and value 172.99, the following code:

<script>var price = {{ price }};</script>

will be rendered as:

<script>var price = 172.99;</script>

JSON

func (d Decimal) JSON() string

JSON returns the representation of d as a JSON number. It allows using a Decimal value in JSON code.

Example

If the price variable has type Decimal and value 172.99, the following code:

<script type="application/ld+json">{ "price": {{ price }} }</script>

will be rendered as:

<script type="application/ld+json">{ "price": 172.99 }</script>

LessThan

func (d Decimal) LessThan(d2 Decimal) bool

LessThan indicates whether d < d2.

LessThanOrEqual

func (d Decimal) LessThanOrEqual(d2 Decimal) bool

LessThanOrEqual indicates whether d <= d2.

Mul

func (d Decimal) Mul(d2 Decimal) Decimal

Mul returns the multiplication d * d2.

Neg

func (d Decimal) Neg() Decimal

Neg returns -d.

Round

func (d Decimal) Round(n int) Decimal

Round returns d rounded to n decimal digits.

String

func (d Decimal) String() string

String returns the representation of d as a string with all its significant decimal digits.

StringN

func (d Decimal) StringN(n int) string

StringN returns the representation of d as a string with exactly n decimal digits. If d has more significant decimal digits than n, it is first truncated to n decimal digits.

Sub

func (d Decimal) Sub(d2 Decimal) Decimal

Sub returns the subtraction d - d2.

Truncate

func (d Decimal) Truncate(n int) Decimal

Truncate returns d truncated to n decimal digits.

type Department

type Department struct {

    // Identifier.
    ID int

    // Name.
    Name LinkedText

    // Small image.
    Image html

    // Child departments.
    ChildDepartments []Department

    // Canonical URL.
    URL string

}

Parent

func (dep Department) Parent() (Department, bool)

Parent returns the parent department and the value true. If the department has no parent, it returns Department{} and false.

Example

{% if parent, ok := dep.Parent(); ok %}
<p>Parent department: {{ parent.Name }}</p>
{% end if %}

type Discount

The Discount type represents a fixed or percentage discount.

type Discount struct {

    // Amount.
    Amount Price

    // Percentage.
    Percent Decimal

}

A Discount value can be displayed directly in HTML:

{{ discount }}

because the HTML method can be called on a value of type Discount. If the Amount field is zero and the Percent field is greater than zero, it shows the value of Percent; otherwise it shows Amount.

Example

If the discount variable has type Discount and value 10.50, the following code:

<b>Discount: {{ discount }}</b>

will be displayed as:

<b>Discount: € 10,50</b>

HTML

func (d Discount) HTML() html

HTML returns the discount in a format suitable for display in an HTML page. If d.Amount == 0 and d.Percent > 0 it shows d.Percent, otherwise d.Amount. The currency and locale are those of the currently rendered page.

IsZero

func (d Discount) IsZero() bool

IsZero indicates whether d.Amount == 0 and d.Percent == 0.

type Duration

The Duration type represents the time difference between two instants in nanoseconds.
The maximum representable duration is about 290 years.

Hours

func (d Duration) Hours() float64

Returns a float64 representing Duration d in hours.

Microseconds

func (d Duration) Microseconds() int64

Returns an int64 representing Duration d in microseconds.

Milliseconds

func (d Duration) Milliseconds() int64

Returns an int64 representing Duration d in milliseconds.

Minutes

func (d Duration) Minutes() float64

Returns a float64 representing Duration d in minutes.

Nanoseconds

func (d Duration) Nanoseconds() int64

Returns an int64 representing Duration d in nanoseconds.

Round

func (d Duration) Round(m Duration) Duration

Returns the result of rounding Duration d to the nearest multiple of m.
For more details, see the documentation for the Scriggo Duration type.

Seconds

func (d Duration) Seconds() float64

Returns a float64 representing Duration d in seconds.

String

func (d Duration) String() string

Returns a string representing Duration d in the format \"72h3m0.5s\".
For more details, see the documentation for the Scriggo Duration type.

Truncate

func (d Duration) Truncate(m Duration) Duration

Returns the result of rounding Duration d toward 0 to a multiple of m.
If m is less than or equal to zero, Truncate returns d.

type File

The File type represents a file uploaded via a form.

type File interface{
    Name() string // name.
    Type() string // type, as mime type.
    Size() int    // size, in bytes.
}

The Name, Type and Size methods allow you to read, respectively, the name, type, and size in bytes of the file.

type Filter

type Filter struct {

    // Ancestor departments of the current department.
    // It is nil if the filter is not by departments.
    Ancestors []FilterAncestor

    // Name or icon of the currently applied value.
    // It is nil if the filter does not allow applying multiple values at the same time.
    AppliedValue FilterItem

    // Indicates whether multiple values can be applied or only one at a time.
    // It can be "multi" or "single".
    ApplyMode string

    // Filter attribute identifier. Meaningful only for
    // attribute filters.
    Attribute int

    // Indicates whether each filter value is shown as a name or icon. It can
    // be "name" or "icon".
    DisplayAs string

    // Indicates whether it is applied, i.e., whether at least one filter
    // value is applied.
    IsApplied bool

    // Indicates whether the filter is by attribute.
    IsByAttribute bool

    // Indicates whether the filter is by departments.
    IsByDepartment bool

    // Indicates whether the filter is by price.
    IsByPrice bool

    // Indicates whether the filter is by producers.
    IsByProducer bool

    // Indicates whether it is expandable, i.e., only some values are always
    // shown and the others are shown when expanding all filter values.
    IsExpandable bool

    // Number of filter values that are initially hidden and are shown only
    // when expanded. It is zero if the filter is by price.
    OnExpandCount int

    // Title.
    Title html

    // Values. For a department filter it is the list of departments, for a
    // producer filter it is the list of producers, for attribute filters it
    // is the list of attribute values, for a price filter it is the list of
    // price ranges unless it is configured to be shown as a slider.
    Values []FilterValue

    //
    // The following fields are meaningful only for price filters.
    //

    // Button to apply the price filter.
    ButtonApply html

    // Currency symbol. Available only for the price filter.
    Currency html

    // Maximum price among filtered products. Available only when shown
    // as a slider.
    MaxPrice Decimal

    // Minimum price among filtered products. Available only when shown
    // as a slider.
    MinPrice Decimal

    // Price from.
    PriceFrom html

    // Price to.
    PriceTo html

    // Slider for selecting a price range. Available only when shown
    // as a slider.
    Slider html

}

type FilterAncestor

The FilterAncestor type represents an ancestor department.

type FilterAncestor struct {

    // Ancestor department identifier.
    ID int

    // Ancestor department name.
    Item AncestorItem

}

type FilterItem

The FilterItem type represents an item in a filter.

FilterItem has only unexported fields, but a value of this type can be displayed directly in HTML:

{{ item }}

because the HTML method can be called on a value of type FilterItem.

HTML

func (item FilterItem) HTML() html

HTML returns the filter item in a format suitable for display in an HTML page.

type FilterValue

The FilterValue type represents a value in a filter.

type FilterValue struct {

    // Identifier. For a department filter it is the department identifier,
    // for a producer filter it is the producer identifier, and for attribute
    // filters it is the attribute value identifier.
    ID int

    // Indicates whether it is applicable. If the filter is configured not to
    // show non-applicable values, then all shown values will be applicable.
    IsApplicable bool

    // Indicates whether it is applied.
    IsApplied bool

    // Name or icon, optionally followed by the product count.
    Item FilterItem

    // Indicates whether it is shown only when filter values are expanded.
    // It can be "yes" or "no".
    OnExpand string

}

type FormData

The FormData type represents data passed with an HTTP request via the query string and body.

type FormData struct{
    // contains unexported fields.
}

ParseMultipart

func (form FormData) ParseMultipart()

ParseMultipart parses the request body as multipart/form-data. If the body is not multipart/form-data, it does nothing. It should be called before calling the File and Files methods and can be called multiple times. It panics if an error occurs.

Value

func (form FormData) Value(field string) string

Value returns the form data, including both parameters passed via the query string and via a form POST. It panics if an error occurs.

Values

func (form FormData) Values() map[string][]string

Values returns the form data, including both parameters passed via the query string and via a form POST. It panics if an error occurs.

File

func (form FormData) File(field string) File

File returns the first file associated with the given field. It returns nil if there are no values associated with the field. Call File only after ParseMultipart has been called.

Files

func (form FormData) Files() map[string][]File

Files returns the files parsed from a multipart form. It returns a non-nil map if ParseMultipart has been called. Call Files only after ParseMultipart has been called.

type Hour

The Hour type represents an hour of the day.

type Hour struct {

    // The hour, can take values 0-23.
    Value int

}

A value of type Hour can be displayed directly in HTML:

{{ startHour }}

because the HTML method can be called on a value of type Hour.

HTML

func (Hour Hour) HTML() html

HTML returns the hour formatted for the current language.

type html

The html type represents HTML code.

type html string

A string value is escaped before being rendered in an HTML context. For example:

{% var s = "<b>hello</b>" %}
{{ s }}

is rendered as:

&lt;b&gt;hello&lt;/b&gt;

Whereas a html value is not escaped in an HTML context. For example:

{% var s = html("<b>hello</b>") %}
{{ s }}

is rendered as:

<b>hello</b>

Conversion from string to html

In the previous example the expression html("<b>hello</b>") was used; it looks like a function call, but since html is a type, it is actually a type conversion. "hello" is a string that is converted to type html.

Scriggo follows Go’s type conversions. However, for html the conversion is allowed only for string literals. For example:

{{ html("<b>hello</b>") }} {# ok #}
{{ html(hello) }} {# error: hello is not a literal but a variable #}

type Image

The Image type represents an image.

type Image struct {

    // Value of the "alt" attribute.
    Alt string

    // Height in pixels.
    Height int

    // Value of the "itemprop" attribute.
    Itemprop string

    // Value of the "title" attribute.
    Title string

    // URL of the single-resolution image.
    URL string

    // URL of the double-resolution image.
    URL2x string

    // Width in pixels.
    Width int

}

A value of type Image can be displayed directly in HTML:

{{ image }}

because the HTML method can be called on a value of type Image.

HTML

func (image Image) HTML() html

HTML returns the image in a format suitable for display in an HTML page.

type InvoiceInList

The InvoiceInList type represents an invoice in the documents.html page.

type InvoiceInList struct {

    // Button to view the invoice.
    ButtonView html

    // Issue date.
    Date Time

    // Number.
    Number string

    // Status.
    Status html

    // Total.
    Total Price

    // Invoice type.
    Type html

    // URL of the invoice detail page.
    URL string

}

type Item

The Item type represents a product item.

type Item struct {

    // Button to add the item to the cart, if stock
    // is greater than zero or the item is still orderable.
    ButtonAddToCart html

    // Depth.
    // Available starting from version 7.2.
    Depth Decimal

    // Discount compared to list price.
    Discount Discount

    // EAN13 code.
    EAN string

    // Height.
    // Available starting from version 7.2.
    Height Decimal

    // Image.
    Image LinkedImage

    // ISBN13 code.
    ISBN string

    // Indicates whether it is for sale.
    IsForSale bool

    // List price.
    ListPrice Price

    // Maximum orderable quantity.
    MaximumOrderQuantity Decimal

    // Minimum orderable quantity.
    MinimumOrderQuantity Decimal

    // Options.
    Options []Option

    // Tax percentage.
    PercentTax Decimal

    // Price.
    Price Price

    // Quantity pricing.
    Prices []PriceTier

    // Quantity to add to the cart. It is empty if
    // stock is zero or the item is not orderable.
    Quantity html

    // Days needed for restocking if not immediately available.
    ReorderDays int

    // Warehouse code.
    SKU string

    // Shipping date.
    ShippingDate Time

    // Available quantity.
    Stock Decimal

    // UPC code.
    UPC string

    // Weight.
    Weight Decimal

    // Width.
    // Available starting from version 7.2.
    Width Decimal

}

type js

The js type represents JavaScript code.

type js string

A string value is escaped before being rendered in a JavaScript context. For example:

{% var s = "alert(message);" %}
{{ s }}

is rendered as:

"alert(message);"

Whereas a js value is not escaped in a JavaScript context. For example:

{% var s = js("alert(message);") %}
{{ s }}

is rendered as:

alert(message);

Conversion from string to js

In the previous example the expression js("alert(message);") was used; it looks like a function call, but since js is a type, it is actually a type conversion. "alert(message);" is a string that is converted to type js.

Scriggo follows Go’s type conversions. However, for js the conversion is allowed only for string literals. For example:

{{ js("alert(message);") }} {# ok #}
{{ js(message) }} {# error: message is not a literal but a variable #}

type json

type Language

The Language type represents a site language.

type Language struct {

    // ISO code, for example "it".
    Code string

    // ISO region, for example "IT".
    Region string

    // Locale. Code and region together, for example "it-IT".
    Locale string

    // Name, for example "Italiano (Italian)".
    Name string

    // URL of the flag image.
    FlagURL string

    // URL of the current page in this language.
    PageURL string

}

type Languages

The Languages type represents the site languages.

type Languages []Language

You can access individual languages:

<ol>
  {% for language in languages %}
  <li><a href="{{ language.PageURL }}">{{ language.Name }}</a></li>
  {% end %}
</ol>

but it can also be displayed directly in HTML:

{{ languages }}

because the HTML method can be called on a value of type Languages.

HTML

func (languages Languages) HTML() html

HTML returns the HTML code that shows the site languages. It returns an empty string if the site has only one language.

IsTrue

func (languages Languages) IsTrue() bool

IsTrue returns true if the site is available in multiple languages.

type LinkedImage

The LinkedImage type represents an image with a link.

type LinkedImage struct {

    // Image.
    Image

}

A value of type LinkedImage can be displayed directly in HTML:

{{ image }}

because the HTML method can be called on a value of type LinkedImage.

HTML

func (image LinkedImage) HTML() html

HTML returns the image in a format suitable for display in an HTML page.

type LinkedText

The LinkedText type represents a text with a link.

type LinkedText struct {

    // Indicates whether the link opens in a new window.
    Blank bool

    // Class.
    Class string

    // Text.
    Text string

    // Title.
    Title string

    // URL.
    URL string

}

A value of type LinkedText can be displayed directly in HTML:

{{ text }}

because the HTML method can be called on a value of type LinkedText.

HTML

func (text LinkedText) HTML() html

HTML returns the text in a format suitable for display in an HTML page.

type markdown

type Mail

The Mail type represents an email to send.

type Mail struct {

    // Sender.
    From        string

    // Recipients.
    To          []string
    
    // CC.
    Cc          []string
    
    // BCC.
    Bcc         []string
    
    // Subject.
    Subject     string
    
    // Body (HTML format).
    Body        html
    
    // Body (plain text).
    TextBody    string

    // Attachments.
    Attachments []File

}

The Menu type represents a single site menu.

type Menu struct {

    // Items
    // In version 7.0 the type is '[]html' instead of '[]MenuItem'.
    Items []MenuItem

    // Menu section name.
    Name string

    // Title
    // In version 7.0 the type is 'html' instead of 'MenuItem'.
    Title MenuItem

}
func (menu Menu) IsZero() bool

IsZero indicates whether len(menu.Items) == 0 and menu.Title == "". It allows using a Menu value as an if condition to check whether it contains items and a title.

{% if menu := menus.Account; menu %}
<div class="menu">
  {% if menu.Title %}<h3>{{ menu.Title }}</h3>{% end %}
  {% if menu.Items %}
  <ul>
    {% for item in menu.Items %}
    <li>{{ item }}</li>
    {% end for %}
  </ul>
  {% end if %}
</div>
{% end if %}

The Menus type represents the site menus. The fields are the names of the menu sections. You can see section names in the Template Editor under Menu by clicking show sections.

type Menus struct {

    // The fields of Menus are the names of the site menu sections.
    // The name "Company" below is just an example.
    Company Menu

}

type NewsletterList

The NewsletterList type represents a newsletter list that users can subscribe to.

type NewsletterList struct {

    // Description.
    Description string

    // Name.
    Name string

    // Checkbox to subscribe to the list.
    Subscription html

}

type Option

The Option type represents an option of a variant.

type Option struct {

    // Name.
    Name string

    // Name of the corresponding variant.
    Variant string

}

type Order

The Order type represents a customer order with its shipments and returns.

type Order struct {

    // Billing address.
    BillingAddress html

    // Button to print the order.
    ButtonPrint html

    // Customer first and last name, or company name.
    CustomerName string

    // Order creation date.
    Date Time

    // Ordered items not yet shipped.
    Items []OrderItem

    // Number.
    Number string

    // Returns.
    Returns []Return

    // Shipments.
    Shipments []Shipment

    // Shipping address.
    ShipmentAddress html

    // Status.
    Status html

    // Total.
    Total Price

}

type OrderInList

The OrderInList type represents an order in the documents.html page.

type OrderInList struct {

    // Button to view the order.
    ButtonView html

    // Creation date.
    Date Time

    // Number.
    Number string

    // Status.
    Status html

    // Total.
    Total Price

    // URL of the order detail page.
    URL string

}

type OrderItem

The OrderItem type represents an order row.

type OrderItem struct {

    // Button to add the item to the cart
    // in the order quantity.
    ButtonAddAllToCart html

    // Button to add the item to the cart
    // in its minimum orderable quantity.
    ButtonAddToCart html

    // Large image, if present.
    LargeImage LinkedImage

    // Medium image, if present.
    MediumImage LinkedImage

    // Name.
    Name html

    // Price.
    Price Price

    // Quantity.
    Quantity Decimal

    // Customer requests.
    Requests string

    // Shipped quantity.
    ShippedQuantity Decimal

    // Warehouse code.
    SKU string

    // Small image, if present.
    SmallImage LinkedImage

    // Tax class code.
    TaxCode string

    // Tax percentage.
    TaxRate Decimal

    // Total price.
    TotalPrice Price

}

type PageNumber

The PageNumber type represents a page number in a pagination.

type PageNumber int

A value of type PageNumber can be displayed directly in HTML:

{{ pageNumber }}

because the HTML method can be called on a value of type PageNumber. The number is displayed only if it is greater than one.

HTML

func (number PageNumber) HTML() html

HTML returns the page number in a format suitable for display in an HTML page. If number <= 1 it returns an empty string.

type Pagination

The Pagination type represents a pagination. It is used for product and order pagination.

type Pagination struct {

    // Current page. The first page is page 1.
    Current int

    // Last page.
    Last int

    // Link text for the next page. It corresponds to the value present
    // in the template translations under the ButtonNextPage entry.
    NextText html

    // Link text for the previous page. It corresponds to the value present
    // in the template translations under the ButtonPreviousPage entry.
    PreviousText html

}

A value of type Pagination, such as the pagination variable, can be displayed directly in HTML to show pagination in the standard format:

{{ pagination }}

because the HTML method can be called on a value of type Pagination.

HTML

func (p Pagination) HTML() html

HTML returns the pagination in a format suitable for display in an HTML page. If p.Last <= 1 it returns an empty string.

IsZero

func (p Pagination) IsZero() bool

IsZero indicates whether pagination is not present, i.e., if p.Last <= 1.

PagePath

func (p Pagination) PagePath(n int) string

PagePath returns the absolute path of the URL for page n. It returns an empty string if n < 1 or if n > p.Last.

Example

The PagePath method can be used to show a custom pagination:

{% for i := 1; i <= p.Last; i++ %}
  {% if i == p.Current %}
    {{ i }}
  {% else %}
    <a href="{{ pagination.PagePath(i) }}">{{ i }}</a>
  { % end if %}
{ % end for %}

type PaymentMethod

The PaymentMethod type represents a payment method that can be selected during checkout.

type PaymentMethod struct {

    // Selectable input for choosing the payment method.
    Choice html

    // Description.
    Description string

    // Name.
    Name html

    // Controls for executing the payment.
    // Currently the only possible values are nil, if the payment method
    // does not support online payment, and a value of type CreditCard,
    // if the method supports credit card payment.
    Pay interface{}

    // Payment provider, for example "Stripe".
    Provider string

}

type Price

The Price type represents a price or cost with and without VAT.

type Price struct {

    // Net price (VAT excluded).
    Net Decimal

    // Gross price (VAT included).
    Gross Decimal

}

A value of type Price can be displayed directly in HTML:

{{ price }}

because the HTML method can be called on a value of type Price. It displays the gross or net price based on the customer.

HTML

func (price Price) HTML() html

HTML returns the price in a format suitable for display in an HTML page. The currency and locale are those of the currently rendered page. HTML displays the gross or net price based on the current customer group.

IsZero

func (p Price) IsZero() bool

IsZero indicates whether p == 0.

JS

func (p Price) JS() string

JS returns the representation of p as a JavaScript number. It allows using a Price value in JavaScript code.

Example

If the price variable has type Price and value 16.99, the following code:

<script>var price = {{ price }};</script>

will be rendered as:

<script>var price = 9.99;</script>

The displayed price will be gross or net depending on the customer. Alternatively, use p.Gross to always show gross and p.Net to always show net.

JSON

func (p Price) JSON() string

JSON returns the representation of p as a JSON number. It allows using a Price value in JSON code.

Example

If the price variable has type Price and value 37.50, the following code:

<script type="application/ld+json">{ "price": {{ price }} }</script>

will be rendered as:

<script type="application/ld+json">{ "price": 37.50 }</script>

The displayed price will be gross or net depending on the customer. Alternatively, use p.Gross to always show gross and p.Net to always show net.

Available starting from version 7.2.44

String

func (p Price) String() string

String returns the price (gross or net based on the current customer group) as a string.

Example

If the price variable has type Price and value 37.50, the following code:

{{ price }}

will be rendered as:

37.50

type PriceTier

The PriceTier type represents a price that varies by quantity.

type PriceTier struct {

    // Discount compared to list price.
    Discount Discount

    // Quantity from which the price applies.
    From Decimal

    // List price.
    ListPrice Price

    // Sale price.
    Price Price

    // Quantity up to which the price applies.
    To Decimal

}

type Processing

The Processing type represents a privacy processing according to GDPR.

type Processing struct {

    // Checkbox to accept consent for the processing.
    Consent html

    // Processing description.
    Description string

    // Unique processing identifier.
    ID int

    // Indicates whether consent is required.
    IsConsentRequired bool

    // Link to the details page.
    MoreInfo html

    // Processing title.
    Title string

}

type ProductImage

The ProductImage type represents a product image.

type ProductImage struct {

    // Image.
    Image

    // URL of the corresponding zoom image.
    ZoomImageURL string

}

A value of type ProductImage can be displayed directly in HTML:

{{ image }}

because the HTML method can be called on a value of type ProductImage.

HTML

func (image ProductImage) HTML() html

HTML returns the image in a format suitable for display in an HTML page.

type PrintedItem

type PrintedItem struct {

    // Name.
    Name string

    // Price.
    Price Price

    // Quantity.
    Quantity Decimal

    // Customer requests.
    Requests string

    // Warehouse code.
    SKU string

    // Tax class code.
    TaxCode string

    // Tax percentage.
    TaxRate Decimal

    // Total price.
    TotalPrice Price

}

type PrintedTax

type PrintedTax struct {

    // Tax amount.
    Amount Decimal

    // Tax class code.
    Code string

    // Tax class name.
    Name string

    // Tax percentage.
    Rate Decimal

    // Taxable total.
    TaxableTotal Decimal

}

type Producer

The Producer type represents a producer.

type Producer struct {
    
    // Identifier.
    ID int
    
    // Name.          
    Name LinkedText
    
    // Logo.
    Logo LinkedImage
    
}

A Producer value can be displayed directly in HTML:

{{ producer }}

because the HTML method can be called on a value of type Producer.

type Product

The Product type represents a product.

type Product struct {

    // Button to add the product to the cart.
    ButtonAddToCart html

    // Button to add the product to the wish list.
    ButtonAddToWishList html

    // Button to remove a product from the wish list,
    // available only on the wish-list.html page.
    ButtonRemove html

    // Product code.
    Code string

    // Product main department.
    Department string

    // Discount compared to list price.
    Discount Discount

    // Product identifier.
    ID int

    // Indicates whether it is for sale.
    IsForSale bool

    // Indicates whether it is a new release.
    IsNewRelease bool

    // Indicates whether it is pre-order.
    IsPreOrder bool

    // Large image. It can be displayed at small or
    // medium size if configured differently in the back office.
    LargeImage LinkedImage

    // List price.
    ListPrice Price

    // Medium image. It can be displayed at small or
    // large size if configured differently in the back office.
    MediumImage LinkedImage

    // Message informing the customer that they can request a quote
    // for the product with a minimum quantity.
    MinQuoteMessage html

    // Name.
    Name LinkedText

    // Tax percentage.
    PercentTax Decimal

    // Product position in the list starting from one. Used
    // especially for best-selling products.
    Position int

    // Message indicating that the product is in pre-order.
    PreOrderMessage html

    // Sale price.
    Price Price

    // Producer.
    Producer string

    // Producer logo.
    ProducerLogo LinkedImage

    // Review rating from 0.0 to 5.0.
    ReviewRating Decimal

    // Short description.
    ShortDescription html

    // Warehouse code of the primary item.
    SKU string

    // Small image. It can be displayed at medium or
    // large size if configured differently in the back office.
    SmallImage LinkedImage

}

type Promotion

The Promotion type represents a promotion.

type Promotion struct {

    // Description.
    Description string

    // Promotion deactivation time.
    EndHour Hour

    // End date.
    EndTime Time

    // Small image.
    Image LinkedImage

    // Indicates whether the promotion is active.
    IsActive bool

    // Large image.
    LargeImage LinkedImage

    // Name.
    Name LinkedText

    // Small image.
    SmallImage LinkedImage

    // Promotion activation time.
    StartHour Hour

    // Start date.
    StartTime Time

}

type PromotionValidity

The PromotionValidity type represents the timing information for a promotion's validity.

type PromotionValidity struct {

    // Promotion end date and time.
    EndTime Time

    // Promotion activation time.
    StartHour Hour

    // Promotion deactivation time.
    EndHour Hour

}

type ProductFile

The ProductFile type represents a file attached to a product.

type ProductFile struct {

    // Description.
    Description LinkedText

    // Size in KB.
    Size string

}

type QuoteInList

The QuoteInList type represents a quote in the documents.html page.

type QuoteInList struct {

    // Button to view the quote.
    ButtonView html

    // Creation date.
    Date Time

    // Number.
    Number string

    // Status.
    Status html

    // Total.
    Total Price

    // URL of the quote detail page.
    URL string

}

type Regexp

The Regexp type represents a regular expression used to search strings.

type Regexp struct {
    // Contains only unexported fields.
}

Match

func (re Regexp) Match(s string) bool

Match indicates whether the string s contains a match of the regular expression.

Find

func (re Regexp) Find(s string) string

Find returns a string with the leftmost match in s of the regular expression.

FindAll

func (re Regexp) FindAll(s string) []string

FindAll returns a slice of all matches of the regular expression.

FindAllSubmatch

func (re Regexp) FindAllSubmatch(s string) [][]string

FindAllSubmatch returns a slice of all submatches of the regular expression.

FindSubmatch

func (re Regexp) FindSubmatch(s string) []string

FindSubmatch returns a slice of the submatches of the regular expression.

ReplaceAll

func (re Regexp) ReplaceAll(src, repl string) string

ReplaceAll returns a copy of src replacing the matches of the regular expression with the string repl.

ReplaceAllFunc

func (re Regexp) ReplaceAllFunc(src, repl func(string) string) string

ReplaceAllFunc returns a copy of src replacing the matches of the regular expression with the return values of the repl function applied to the match substrings.

Split

func (re Regexp) Split(s string, n int) []string

Split splits s into substrings separated by the regular expression and returns a slice of the substrings between the matches.

type Resource

The Resource type represents a resource such as a product, department, or producer.

type Resource struct {

    // Identifier.
    ID int

    // Type. Can be "Department", "Product", "Producer",
    // "AttributeValue", "Promotion", "Page" or "BlogPost".
    Type string

}

type Return

The Return type represents a return.

type Return struct {

    // Button to print the return.
    ButtonPrint html

    // Date when the return request was made.
    Date Time

    // Items for which a return was requested.
    Items []ReturnItem

    // Number.
    Number string

    // Status.
    Status html

}

type ReturnItem

The ReturnItem type represents a return row.

type ReturnItem struct {

    // Approval status of the product return.
    Approval html

    // Customer comments on the product provided with the return request.
    Comments string

    // Large image, if present.
    LargeImage LinkedImage

    // Medium image, if present.
    MediumImage LinkedImage

    // Name.
    Name html

    // Price.
    Price Price

    // Quantity.
    Quantity Decimal

    // Reason for the return request.
    Reason string

    // Warehouse code.
    SKU string

    // Small image, if present.
    SmallImage LinkedImage

    // Tax class code.
    TaxCode string

    // Tax percentage.
    TaxRate Decimal

}

type ReturnableItem

The ReturnableItem type represents an item that can be returned.

type ReturnableItem struct {

    // Selectable input to add the item to the return.
    AddToReturn html

    // Customer comments.
    Comments html

    // Delivery date of the related shipment.
    DeliveryDate Time

    // Item identifier within the return.
    ID string

    // Information about return conditions.
    Info string

    // Name.
    Name string

    // Related order number.
    OrderNumber string

    // Quantity to return.
    Quantity TextField

    // Menu for choosing the return reason.
    Reasons html

    // Maximum returnable quantity.
    ReturnableQuantity Decimal

    // Warehouse code.
    SKU string

}

type Review

The Review type represents a product review.

type Review struct {

    // Author.
    Author string

    // Code.
    Code string

    // Content.
    Content string

    // Date.
    Date Time

    // Rating from 0.0 to 5.0.
    Rating Decimal

    // Summary.
    Summary string

}

type ShippingMethod

The ShippingMethod type represents a shipping method that can be selected during checkout.

type ShippingMethod struct {

    // Selectable input for choosing the shipping method.
    Choice html

    // Name.
    Name html

}

type Shipment

The Shipment type represents a shipment.

type Shipment struct {

    // Button to return items.
    ButtonReturnItems html

    // Delivery date.
    DeliveryDate Time

    // Shipped items.
    Items []ShipmentItem

    // Shipment date.
    ShipmentDate Time

    // Tracking number.
    TrackingNumber string

    // Link to the tracking page.
    TrackingURL html

}

type ShipmentItem

The ShipmentItem type represents a shipment row.

type ShipmentItem struct {

    // Button to add the item to the cart
    // in the shipment quantity.
    ButtonAddAllToCart html

    // Button to add the item to the cart
    // in its minimum orderable quantity.
    ButtonAddToCart html

    // Indicates whether a return can be requested.
    IsReturnable bool

    // Large image, if present.
    LargeImage LinkedImage

    // Last day to request a return.
    LastDateToReturn Time

    // Medium image, if present.
    MediumImage LinkedImage

    // Name.
    Name html

    // Price.
    Price Price

    // Quantity.
    Quantity Decimal

    // Customer requests.
    Requests string

    // Warehouse code.
    SKU string

    // Small image, if present.
    SmallImage LinkedImage

    // Tax class code.
    TaxCode string

    // Tax percentage.
    TaxRate Decimal

}

type SiblingDepartment

The SiblingDepartment type represents the sibling department of a given department.

type SiblingDepartment struct {

    // Small image.
    Image LinkedImage

    // Name.
    Name LinkedText

}

type Snippet

The Snippet type represents a snippet returned by the snippet function.

It contains only unexported fields, but a value of this type can be displayed directly in HTML:

{{ snippet("rating") }}

because the HTML method can be called on a value of type Snippet. If there is no snippet with the name passed to the snippet function, it displays an HTML comment with the error message.

Error

func (s Snippet) Error() error

Error returns the error that occurred while reading the snippet. It returns nil if no error occurred.

HTML

func (s Snippet) HTML() html

HTML returns the snippet in a format suitable for inclusion in HTML code.

type TextField

The TextField type represents a text field in a form.

type TextField struct {

    // Error that occurred when filling the field.
    Error html

    // Indicates whether the field is required.
    Required bool

    // The field value.
    Value string

}

A value of type TextField can be displayed directly in HTML:

{{ item }}

because the HTML method can be called on a value of type TextField.

HTML

func (field TextField) HTML() html

HTML returns the field in a format suitable for display in an HTML page.

type Thumbnail

The Thumbnail type represents a thumbnail of a product image.

type Thumbnail struct {

    // Image.
    Image

    // URL of the corresponding large image.
    LargeImageURL string

    // URL of the corresponding zoom image.
    ZoomImageURL string

}

type Thumbnails

The Thumbnails type represents the thumbnails of a product's images.

type Thumbnails []Thumbnail

A value of type Thumbnails can be displayed directly in HTML:

{{ thumbnails }}

because the HTML method can be called on a value of type Thumbnails.

HTML

func (t Thumbnails) HTML() html

HTML returns the thumbnails in a format suitable for display in an HTML page.

type Time

The Time type represents a point in time.

type Time struct {
    // Contains only unexported fields.
}

Add

func (t Time) Add(d builtin.Duration) Time

Add returns the Time t+d.

AddDate

func (t Time) AddDate(years, months, days int) Time

AddDate returns the Time obtained by adding years years, months months, and days days to t. For example, AddDate(-1, 2, 3) applied to January 1, 2011 returns March 4, 2010.

After

func (t Time) After(u Time) bool

After indicates whether the instant t is after u.

func (t Time) Before(u Time) bool

Before indicates whether the instant t is before u.

Clock

func (t Time) Clock() (hour, minute, second int)

Clock returns the hour, minute, and second in the day specified by t. hour is between 0 and 23, minute and second are between 0 and 59.

Date

func (t Time) Date() (year, month, day int)

Date returns the year, month, and day in which t falls. month is between 1 and 12, day is between 1 and 31.

Day

func (t Time) Day() int

Day returns the day on which t falls. The result is between 1 and 31.

Equal

func (t Time) Equal(u Time) bool

Equal indicates whether t and u represent the same instant.

Format

func (t Time) Format(layout string) string

Format returns the textual representation of t formatted according to layout.
layout defines the format by showing how the reference time

Mon Jan 2 15:04:05 -0700 MST 2006

would be displayed if it were the value of t.
For example, Format("01/02/2006 15:04") applied to 12:30 on February 21, 2022 returns "21/02/2022 12:30".

Hour

func (t Time) Hour() int

Hour returns the hour of the day in which t falls. The result is between 0 and 23.

IsZero

func (t Time) IsZero() bool

IsZero indicates whether t represents the zero instant, i.e., January 1 of year 1 at 0:00:00 UTC.

JS

func (t Time) JS() JS

JS returns t as a JavaScript date. The result is undefined if the year of t is not between -999999 and 999999.

JSON

func (t Time) JSON() JSON

JSON returns t in a format usable in JSON.

Month

func (t Time) Month() int

Month returns the month of the year specified by t. The returned value is between 1 and 12, where 1 is January and 12 is December.

Minute

func (t Time) Minute() int

Minute returns the minute of the hour specified by t. The returned value is between 0 and 59.

Nanosecond

func (t Time) Nanosecond() int

Nanosecond returns the nanosecond within the second specified by t. The returned value is between 0 and 999999999.

Round

func (t Time) Round(d builtin.Duration) Time

Round returns the result of rounding t to the nearest multiple of d (from Time zero). Rounding is performed away from zero.

Second

func (t Time) Second() int

Second returns the second in the minute specified by t. The returned value is between 0 and 59.

String

func (t Time) String() string

String returns the textual representation of t formatted using the layout "2006-01-02 15:04:05.999999999 -0700 MST".

Sub

func (t Time) Sub(u Time) Duration

Sub returns the Duration t-u. To compute t-d for the Duration d, use t.Add(-d).

Truncate

func (t Time) Truncate(d Duration) Time

Truncate returns the result of truncating t to the nearest multiple of d (from Time zero).

UTC

func (t Time) UTC() Time

UTC returns t with the location set to UTC.

Unix

func (t Time) Unix() int64

Unix returns t as Unix time, i.e., the number of seconds elapsed since January 1, 1970 UTC.

UnixNano

func (t Time) UnixNano() int64

UnixNano returns t as the number of nanoseconds elapsed since January 1, 1970 UTC.

Weekday

func (t Time) Weekday() int

Weekday returns the weekday specified by t.

Year

func (t Time) Year() int

Year returns the year in which t falls.

YearDay

func (t Time) YearDay() int

YearDay returns the day of the year specified by t. The returned value is between 1 and 365 for non-leap years, and between 1 and 366 for leap years.

type Variant

The Variant type represents a variant.

type Variant struct {

    // Name.
    Name string

    // Options.
    Options html

}