Skip to content

gobuffalo/helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Helpers

Standard Test Go Reference


Note: This file is auto-generated. Do Not Edit

Form implements a github.com/gobuffalo/plush helper around the bootstrap.New function in the github.com/gobuffalo/tags/form/bootstrap package

FormFor implements a github.com/gobuffalo/plush helper around the bootstrap.NewFormFor function in the github.com/gobuffalo/tags/form/bootstrap package

New returns a map of the helpers within this package.

RemoteForm implements a github.com/gobuffalo/plush helper around the bootstrap.New function in the github.com/gobuffalo/tags/form/bootstrap package

FormFor implements a github.com/gobuffalo/plush helper around the bootstrap.NewFormFor function in the github.com/gobuffalo/tags/form/bootstrap package

<%= remoteFormFor(widget, {method: "POST"}) { %>
<% } %>
<form action="/widgets/b6b0ab24-19ae-4cdd-ad73-c5ecbddd6f91" id="widget-form" method="POST"><input name="_method" type="hidden" value="PUT"></form>

ContentFor stores a block of templating code to be re-used later in the template via the contentOf helper. An optional map of values can be passed to contentOf, which are made available to the contentFor block.

<% contentFor("buttons") { %>
    <button>hi</button>
<% } %>

ContentOf retrieves a stored block for templating and renders it. You can pass an optional map of fields that will be set.

<%= contentOf("buttons") %>
<%= contentOf("buttons", {"label": "Click me"}) %>

New returns a map of the helpers within this package.

WithDefault allows to get the value from a key in the context or a default value if not present.

Debug by verbosely printing out using 'pre' tags.

Inspect the interface using the %+v formatter

New returns a map of the helpers within this package.

New returns a map of the helpers within this package.

Raw converts a string to a template.HTML

ToJSON marshals the interface{} and returns it as template.HTML

New returns a map of the helpers within this package.

HTMLEscape will escape a string for HTML

New returns a map of the helpers within this package.

Form implements a github.com/gobuffalo/plush helper around the form.New function in the github.com/gobuffalo/tags/form package

FormFor implements a github.com/gobuffalo/plush helper around the form.NewFormFor function in the github.com/gobuffalo/tags/form package

New returns a map of the helpers within this package.

RemoteForm implements a github.com/gobuffalo/plush helper around the form.New function in the github.com/gobuffalo/tags/form package

RemoteFormFor implements a github.com/gobuffalo/plush helper around the form.NewFormFor function in the github.com/gobuffalo/tags/form package

<%= remoteFormFor(widget, {method: "POST"}) { %>
<% } %>
<form action="/widgets/b6b0ab24-19ae-4cdd-ad73-c5ecbddd6f91" id="widget-form" method="POST"><input name="_method" type="hidden" value="PUT"></form>

New returns a map of the helpers within this package.

Between will iterate up to, but not including b

Between(0,10) // 0,1,2,3,4,5,6,7,8,9

GroupBy creates an iterator of groups or sub-slices of the underlying Array or Slice entered where each group is of length Len(underlying) / size. If Len(underlying) == size it will return an iterator with only a single group.

New returns a map of the helpers within this package.

Next returns the next group from the GroupBy

Next returns the next number in the Range or nil

Range creates an Iterator that will iterate numbers from a to b, including b.

Until will iterate up to, but not including a

Until(3) // 0,1,2

Len returns the length of v

New returns a map of the helpers within this package.

New returns a map of the helpers within this package.

PathFor takes an interface{}, or a slice of them, and tries to convert it to a /foos/{id} style URL path. Rules:

  • if string it is returned as is
  • if Pathable the ToPath method is returned
  • if slice or an array each element is run through the helper then joined
  • if struct the name of the struct, pluralized is used for the name
  • if Paramable the ToParam method is used to fill the {id} slot
  • if struct.Slug the slug is used to fill the {id} slot of the URL
  • if struct.ID the ID is used to fill the {id} slot of the URL

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.

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

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.

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

New returns a map of the helpers within this package.

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>

Markdown converts the string into HTML using GitHub flavored markdown.

New returns a map of the helpers within this package.

Truncate will try to return a string that is no longer than size, which defaults to 50. If given a trail option the returned string will have that appended at the end, while still trying to make sure that the returned string is no longer than size characters long. However, if trail is longer than or equal to size, trail will be returned completely as is. Defaults to a trail of ....