request

The request object has attributes of the current state of the web page.

request.format

Returns format of current request.

Input (on regular url, like /posts)

{{ request.format }}

Output:

"html"

 

Input (on specific url, like /posts.xml)

{{ request.format }}

Output:

Request.format only allows: xml, html and json.

 

request.fullpath

Returns full path, include query string.

Input:

Output:

request.language

Returns a language object for the current language.

Input:

On a post that has the german language, e.g. /de/deutches-post

Output:

request.path

Returns only path, without query string.

Input:

Output:

request.query

Returns query string. Everything after ‘?’.

Input:

Output:

Be aware of the risk of cross site scripting (XSS) vulnerability. Do not directly render the query string in your templates.

request.query_object

Converts the query string into an object

Input:

Output:

Input:

Output:

Be aware of the risk of cross site scripting (XSS) vulnerability. Do not directly render any query object variable in your templates.

request.url

Returns the full current url.

Input:

Output:

request.flash

Contains browser flash messages like form errors.

Input:

Output:

request.user_agent

Returns the user agent.

Input

Output:

request.body

Returns the request body for POST and PUT requests. Returns `nil` on GET requests

Input:

Output:

request.request_method

Returns HTTP request method for current request. One of GET, POST or PUT.

Input

Output:

 

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.

Input:

Output:

If user is logged into the inline CMS:

If user is not logged into the inline CMS: