request
The request object has attributes of the current state of the web page.
request.format
Returns format of current request.
{{ request.format }}
"html"
{{ request.format }}
"xml"
request.fullpath
Returns full path, include query string.
{{ request.fullpath }}
/this/is-a/path?full=1
request.language
Returns a language object for the current language.
{{ request.language }}
{ "shortcode" => "de", "name" => "German, "url" => "/de/deutches-post" }
request.path
Returns only path, without query string.
{{ request.path }}
/this/is-a/path
request.query
Returns query string. Everything after ‘?’.
{{ request.query }}
full=1&page=5
request.query_object
Converts the query string into an object
{{ request.query_object }}
{"full" => "1", "page" => "5"}
{{ request.query_object.page }}
5
request.url
Returns the full current url.
{{ request.url }}
https://www.my-plate-site.com/this/is-a/path?full=1
request.flash
Contains browser flash messages like form errors.
{{ request.flash.alert }}
{% for error_msg in request.flash.errors %}
- {{ error_msg }}
{% endfor %}
Something went wrong while sending the message.
- Name is required
- Email is invalid
request.user_agent
Returns the user agent.
{{ request.user_agent }}
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
request.body
Returns the request body for POST and PUT requests. Returns `nil` on GET requests
{{ request.body }}
{"param" => "yourbodyparam"}
request.request_method
Returns HTTP request method for current request. One of GET, POST or PUT.
{{ request.request_method }}
"GET"
request.inline_cms_active
Returns true when the request comes from a user using the inline CMS. So this returns false when a regular site visitor visits a page. This allows for showing/hiding specific data to CMS users or site visitors.
{% if request.inline_cms_active %}
Inline CMS is now active
{% else %}
This will be visible only to persons not logged into the inline CMS
{% endif %}
Inline CMS is now active
This will be visible only to persons not logged into the inline CMS
request.csp_nonce
Returns the nonce that can be used for inline scripts to implement the Content Security Policy of your site properly.
<script nonce="{{ request.csp_nonce }}">
...
</script>
<script nonce="Rand)mNonCe">
...
</script>