Unpoly v1.2.1 Unpoly View Source
A Plug adapter and helpers for Unpoly, the unobtrusive JavaScript framework.
Options
:cookie_name
- the cookie name where the request method is echoed to. Defaults to"_up_method"
.:cookie_opts
- additional options to pass to method cookie. SeePlug.Conn.put_resp_cookie/4
for all available options.
Link to this section Summary
Functions
Returns whether the given CSS selector is targeted by the current fragment update for either a success or a failed response.
Returns the CSS selector for a fragment that Unpoly will update in case of an failed response. Server errors or validation failures are all examples for a failed response (non-200 status code).
Returns whether the given CSS selector is targeted by the current fragment update in case of a failed response (non-200 status code).
Sets the value of the "x-up-location" response header.
Sets the value of the "x-up-method" response header.
Forces Unpoly to use the given string as the document title when processing this response.
Returns the CSS selector for a fragment that Unpoly will update in case of a successful response (200 status code).
Returns whether the given CSS selector is targeted by the current fragment update in case of a successful response (200 status code).
Returns whether the current request is a page fragment update triggered by an Unpoly frontend.
Alias for Unpoly.unpoly?/1
Returns whether the current form submission should be validated (and not be saved to the database).
If the current form submission is a validation, this returns the name attribute of the form field that has triggered the validation.
Link to this section Functions
any_target?(conn, tested_target)
View Sourceany_target?(Plug.Conn.t(), String.t()) :: boolean()
Returns whether the given CSS selector is targeted by the current fragment update for either a success or a failed response.
Note that the matching logic is very simplistic and does not actually know
how your page layout is structured. It will return true
if
the tested selector and the requested CSS selector matches exactly, or if the
requested selector is body
or html
.
Always returns true
if the current request is not an Unpoly fragment update.
Returns the CSS selector for a fragment that Unpoly will update in case of an failed response. Server errors or validation failures are all examples for a failed response (non-200 status code).
The Unpoly frontend will expect an HTML response containing an element that matches this selector.
Server-side code is free to optimize its response by only returning HTML that matches this selector.
fail_target?(conn, tested_target)
View Sourcefail_target?(Plug.Conn.t(), String.t()) :: boolean()
Returns whether the given CSS selector is targeted by the current fragment update in case of a failed response (non-200 status code).
Note that the matching logic is very simplistic and does not actually know
how your page layout is structured. It will return true
if
the tested selector and the requested CSS selector matches exactly, or if the
requested selector is body
or html
.
Always returns true
if the current request is not an Unpoly fragment update.
put_resp_location_header(conn, value)
View Sourceput_resp_location_header(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Sets the value of the "x-up-location" response header.
put_resp_method_header(conn, value)
View Sourceput_resp_method_header(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Sets the value of the "x-up-method" response header.
put_title(conn, new_title)
View Sourceput_title(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
Forces Unpoly to use the given string as the document title when processing this response.
This is useful when you skip rendering the <head>
in an Unpoly request.
Returns the CSS selector for a fragment that Unpoly will update in case of a successful response (200 status code).
The Unpoly frontend will expect an HTML response containing an element that matches this selector.
Server-side code is free to optimize its successful response by only returning HTML that matches this selector.
target?(conn, tested_target)
View Sourcetarget?(Plug.Conn.t(), String.t()) :: boolean()
Returns whether the given CSS selector is targeted by the current fragment update in case of a successful response (200 status code).
Note that the matching logic is very simplistic and does not actually know
how your page layout is structured. It will return true
if
the tested selector and the requested CSS selector matches exactly, or if the
requested selector is body
or html
.
Always returns true
if the current request is not an Unpoly fragment update.
Returns whether the current request is a page fragment update triggered by an Unpoly frontend.
Alias for Unpoly.unpoly?/1
Returns whether the current form submission should be validated (and not be saved to the database).
validate_name(conn)
View Sourcevalidate_name(Plug.Conn.t()) :: String.t() | nil
If the current form submission is a validation, this returns the name attribute of the form field that has triggered the validation.