tags

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ImgKey          = "imgTag"
	CSSKey          = "stylesheetTag"
	JSKey           = "javascriptTag"
	LinkToKey       = "linkTo"
	RemoteLinkToKey = "remoteLinkTo"
)

Keys to be used in templates for the functions in this package.

Variables

This section is empty.

Functions

func CSS

func CSS(href string, options tags.Options) template.HTML

CSS creates html for a css link using `github.com/gobuffalo/tags` to create a link with the given options and href. Defaults to `stylesheet` for `rel` and `screen` for `media` if those options are not set.

func Img

func Img(src string, options tags.Options) template.HTML

Img creates html for a `<img>` tag using `github.com/gobuffalo/tags` to create a tag with the given `src` and `options`.

func JS

func JS(src string, options tags.Options) template.HTML

JS creates html for a `<script>` tag using `github.com/gobuffalo/tags` to create the tag with the given `options` and `src`. Defaults to `text/javascript` for `type` if not set in the `options`.

func LinkTo

func LinkTo(in interface{}, opts tags.Options, help hctx.HelperContext) (template.HTML, error)

LinkTo creates html for a `<a>` tag using `github.com/gobuffalo/tags` to create tag with the given options(`opts`) and using [`paths#PathFor(in)`](https://godoc.org/github.com/gobuffalo/helpers/paths#PathFor) to set the `href`. If given a block it will be interrupted and appended inside of the `<a>` tag. Example 1:

<%= linkTo([user, widget], {class: "btn"}) %>

yields(assuming user ID'd by `id` and widget by `slug`):

<a class="btn" href="/users/id/widget/slug"></a>

Example 2:

<%= linkTo("foo", {class: "btn"}) %>

yields:

<a class="btn" href="/foo"></a>

func New

func New() hctx.Map

New returns a map of the helpers within this package.

func RemoteLinkTo

func RemoteLinkTo(in interface{}, opts tags.Options, help hctx.HelperContext) (template.HTML, error)

RemoteLinkTo creates an AJAXified `<a>` tag.

<%= remoteLinkTo(widget, {class: "btn btn-info", body: "View"}) %>
<a class="btn btn-info" data-remote="true" href="/widgets/b6b0ab24-19ae-4cdd-ad73-c5ecbddd6f91">View</a>

Types

This section is empty.

Jump to

Keyboard shortcuts

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