tags

package module
v2.1.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 12 Imported by: 55

README

Build Status Go Report Card

Tags

Easily build HTML tags in Go! This package is especially useful when using http://gobuffalo.io.

Getting Started

Prerequisites

Tags has a minimum Go dependency of 1.8.1.

Installing

To get this lib just get it via go get

go get -u -v github.com/gobuffalo/tags/...

Running the tests

In order to run the tests just do it with a regular

go test ./...

Documentation

Documentation is currently in this repository Wiki, you can find there instructions on how to use tags within your app.

Contributing

If you want to contribute, please read this article first: Contributing to Open Source Git Repositories in Go. It shows how to configure your git environment to avoid common pitfalls. This article is recommended to all those who are looking to contribute to any Go projects.

^ Taken from gobuffalo.io

⚠️ Send PRs to development branch

The way we release in Tags is:

  1. We use development branch to accumulate changes to be released
  2. Once we decide to make a release we send a PR from development to master with those changes to be added.
  3. Once that PR gets merged we tag a new release with the vX.X.X scheme.

Documentation

Index

Constants

View Source
const Version = "v2.1.0"

Version holds current source version number

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterTag

type AfterTag interface{}

AfterTag is content placed right after the Tag

type BeforeTag

type BeforeTag interface{}

BeforeTag is content placed right before the Tag

type Body

type Body interface{}

Body is a Tag inner content.

type EncodedBody

type EncodedBody interface{}

EncodedBody is a Tag inner text content (HTML encoded).

type Options

type Options map[string]interface{}

Options is a map used to configure tags

func (Options) String

func (o Options) String() string

type Paginator

type Paginator struct {
	// Current page you're on
	Page int `json:"page"`
	// Number of results you want per page
	PerPage int `json:"per_page"`
	// Page * PerPage (ex: 2 * 20, Offset == 40)
	Offset int `json:"offset"`
	// Total potential records matching the query
	TotalEntriesSize int `json:"total_entries_size"`
	// Total records returns, will be <= PerPage
	CurrentEntriesSize int `json:"current_entries_size"`
	// Total pages
	TotalPages int `json:"total_pages"`
}

Paginator describes a pagination meta data

func (Paginator) Tag

func (p Paginator) Tag(opts Options) (*Tag, error)

Tag generates the pagination html Tag

func (Paginator) TagFromPagination

func (p Paginator) TagFromPagination(pagination interface{}, opts Options) (*Tag, error)

TagFromPagination receives a pagination interface{} and attempts to get Paginator properties from it before generating the tag.

type Tag

type Tag struct {
	Name        string
	Options     Options
	Selected    bool
	Checked     bool
	BeforeTag   []BeforeTag
	Body        []Body
	EncodedBody []EncodedBody
	AfterTag    []AfterTag
}

Tag describes a HTML tag meta data.

func JavascriptTag

func JavascriptTag(opts Options) *Tag

JavascriptTag builds JS tags based in passed options

func New

func New(name string, opts Options) *Tag

New creates a new Tag with given name and options.

func Pagination

func Pagination(pagination interface{}, opts Options) (*Tag, error)

Pagination builds pagination Tag based on a passed pagintation interface

func StylesheetTag

func StylesheetTag(opts Options) *Tag

StylesheetTag builds the <link> tag to load styles on the page.

func (*Tag) Append

func (t *Tag) Append(b ...Body)

Append adds new Body part(s) after the current Tag inner contents.

func (Tag) HTML

func (t Tag) HTML() template.HTML

HTML gets the Tag string representation as a HTML template.

func (*Tag) Prepend

func (t *Tag) Prepend(b ...Body)

Prepend adds new Body part(s) before the current Tag inner contents.

func (Tag) String

func (t Tag) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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