• Module: core

This model gives access to the request variables from within a template.

Sometimes you need direct access to request variables in your template. The m_req model is meant for this. It exposes some values from the Webmachine request record.

Fetching a single value

You can fetch individual values by key, for example:

{{ m.req.host|escape }}

Viewing all request variables

Use the print tag to get a complete overview of all request variables:

{% print m.req|make_list %}

This will show something like:

         {"accept-encoding","gzip, deflate"},
         {"cookie","z_sid=1RrDIvFVsoyLgtSU62mN; z_pid=HRrAaiPI08Il4Nu4wST1"},
          "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16"}]}]

Please note that all values are raw and not escaped, take care to escape the values before you use them in your templates, using the filter-escape filter.

The make_list filter is used to force the evaluation of the model; otherwise it would just print {m,req,undefined}.

Table Of Contents

Previous topic


Next topic