module Amber::Controller::Helpers::URLHelpers

Direct including types

Defined in:

amber/controller/helpers/url_helpers.cr

Instance Method Summary

Instance Method Detail

def button_to(text : String, url : String, method : String = "POST", **attrs) : String #

Generates a form containing a single submit button for non-GET actions. Useful for delete links and other actions that should not be plain links.

button_to("Delete", "/users/1", method: "DELETE")

[View source]
def link_back(text : String = "Back", **attrs) : String #

Generates a link back to the previous page using the Referer header. Falls back to "#" if no referer is present.

link_back                  # => "<a href=\"/previous\">Back</a>"
link_back(text: "Go Back") # => "<a href=\"/previous\">Go Back</a>"

[View source]
def link_to(text : String, url : String, **attrs) : String #

Generates an anchor tag.

link_to("Home", "/") # => "<a href=\"/\">Home</a>"
link_to("Profile", "/users/1", class: "nav-link")

[View source]
def mail_to(email : String, text : String | Nil = nil, **attrs) : String #

Generates a mailto link.

mail_to("[email protected]")                   # => "<a href=\"mailto:[email protected]\">[email protected]</a>"
mail_to("[email protected]", text: "Email us") # => "<a href=\"mailto:[email protected]\">Email us</a>"

[View source]