helpers: Index | Files

package tags

import ""


Package Files

back_url.go css.go img.go js.go link_to.go tags.go


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.

func BackURL Uses

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 Uses

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

CSS creates html for a css link using `` 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 Uses

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

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

func JS Uses

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

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

func LinkTo Uses

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

LinkTo creates html for a `<a>` tag using `` to create tag with the given options(`opts`) and using [`paths#PathFor(in)`]( 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 Uses

func New() hctx.Map

New returns a map of the helpers within this package.

func RemoteLinkTo Uses

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>

Package tags imports 6 packages (graph) and is imported by 5 packages. Updated 2020-01-16. Refresh now. Tools for package owners.