tags

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 6 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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

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

Variables

This section is empty.

Functions

func BackURL added in v0.2.3

func BackURL(help hctx.HelperContext) string

BackURL returns a URL to the referer, if its presend in the "Referer" header it will take it from there. Otherwise it will return "javascript:history.back()" and rely on the browser history.

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", body: "View"}) %>

yields:

<a class="btn" href="/foo">View</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