Skip to content

Commit

Permalink
added documentation for url_for compress flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tsilva committed Apr 20, 2015
1 parent cbce70b commit 61c3bc5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion doc/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ The `absolute` named argument will make the resolved URL be prefixed with the va
in the `BASE_URL` configuration setting. To learn more, read the [Configuration](configuration.md)
documentation.

And finally, here's how to access static resources in the app:
Here's how to access static resources in the app:

```html
<img src="{{ url_for('static', filename = 'images/cats/felix.png') }}" />
```

In case you want the resource to be compressed to lessen bandwidth usage, you can pass the `compress` flag.

```html
<img src="{{ url_for('static', filename = 'images/cats/felix.png', compress = True) }}" />
```

In this example, the flag will have a behaviour appropriate to the specified resource.
In this case, it would return a JPEG instead of a PNG (the JPEG would be created on-the-fly
and cached, so future requests won't trigger compression again).

The previous example will output a link to `static/images/cats/felix.png` from
the root of your app location. All static resources like CSS, Javascript, Images,
and others, should be stored inside the `static` directory (read the [Structure](structure.md)
Expand Down

0 comments on commit 61c3bc5

Please sign in to comment.