Version: v0.6.6 Latest Latest

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 6 Imported by: 2




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.


This section is empty.


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"}) %>


<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>


This section is empty.

Jump to

Keyboard shortcuts

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