summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-06-16 11:01:25 -0700
committerSteve Piercy <web@stevepiercy.com>2016-06-16 11:01:25 -0700
commit715ec5efbc3fc46e8e1cfef458667bded49d243e (patch)
tree72e29b69170d0ce9afe14ff093371a054538b422
parent32697a643949121fd7f4f81c364c365b9c55107f (diff)
downloadpyramid-715ec5efbc3fc46e8e1cfef458667bded49d243e.tar.gz
pyramid-715ec5efbc3fc46e8e1cfef458667bded49d243e.tar.bz2
pyramid-715ec5efbc3fc46e8e1cfef458667bded49d243e.zip
Quick Tour - static_assets - closes #2648
- swap contents of jinja2 templates - use __main__ to specify package - carry forward template to json step - use :language: python directive for correct syntax highlighting
-rw-r--r--docs/quick_tour.rst13
-rw-r--r--docs/quick_tour/json/hello_world.jinja22
-rw-r--r--docs/quick_tour/static_assets/hello_world.jinja22
-rw-r--r--docs/quick_tour/static_assets/hello_world_static.jinja22
4 files changed, 10 insertions, 9 deletions
diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst
index b170e5d98..55557f501 100644
--- a/docs/quick_tour.rst
+++ b/docs/quick_tour.rst
@@ -339,9 +339,10 @@ Static assets
Of course the Web is more than just markup. You need static assets: CSS, JS,
and images. Let's point our web app at a directory from which Pyramid will
serve some static assets. First let's make another call to the
-:term:`configurator`:
+:term:`configurator` in ``app.py``:
.. literalinclude:: quick_tour/static_assets/app.py
+ :language: python
:linenos:
:lines: 6-8
:lineno-start: 6
@@ -359,7 +360,7 @@ Next make a directory named ``static``, and place ``app.css`` inside:
All we need to do now is point to it in the ``<head>`` of our Jinja2 template,
``hello_world.jinja2``:
-.. literalinclude:: quick_tour/static_assets/hello_world.jinja2
+.. literalinclude:: quick_tour/static_assets/hello_world_static.jinja2
:language: jinja
:linenos:
:lines: 4-6
@@ -371,16 +372,16 @@ the site is later moved under ``/somesite/static/``? Or perhaps a web developer
changes the arrangement on disk? Pyramid provides a helper to allow flexibility
on URL generation:
-.. literalinclude:: quick_tour/static_assets/hello_world_static.jinja2
+.. literalinclude:: quick_tour/static_assets/hello_world.jinja2
:language: jinja
:linenos:
:lines: 4-6
:lineno-start: 4
:emphasize-lines: 2
-By using ``request.static_url`` to generate the full URL to the static
-assets, you both ensure you stay in sync with the configuration and
-gain refactoring flexibility later.
+By using ``request.static_url`` to generate the full URL to the static assets,
+you ensure that you stay in sync with the configuration and gain refactoring
+flexibility later.
.. seealso:: See also:
:ref:`Quick Tutorial Static Assets <qtut_static_assets>`,
diff --git a/docs/quick_tour/json/hello_world.jinja2 b/docs/quick_tour/json/hello_world.jinja2
index 4fb9be074..a55865231 100644
--- a/docs/quick_tour/json/hello_world.jinja2
+++ b/docs/quick_tour/json/hello_world.jinja2
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Hello World</title>
- <link rel="stylesheet" href="{{ request.static_url('static/app.css') }}"/>
+ <link rel="stylesheet" href="{{ request.static_url('__main__:static/app.css') }}"/>
</head>
<body>
<h1>Hello {{ name }}!</h1>
diff --git a/docs/quick_tour/static_assets/hello_world.jinja2 b/docs/quick_tour/static_assets/hello_world.jinja2
index 0fb2ce296..a55865231 100644
--- a/docs/quick_tour/static_assets/hello_world.jinja2
+++ b/docs/quick_tour/static_assets/hello_world.jinja2
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Hello World</title>
- <link rel="stylesheet" href="/static/app.css"/>
+ <link rel="stylesheet" href="{{ request.static_url('__main__:static/app.css') }}"/>
</head>
<body>
<h1>Hello {{ name }}!</h1>
diff --git a/docs/quick_tour/static_assets/hello_world_static.jinja2 b/docs/quick_tour/static_assets/hello_world_static.jinja2
index 4fb9be074..0fb2ce296 100644
--- a/docs/quick_tour/static_assets/hello_world_static.jinja2
+++ b/docs/quick_tour/static_assets/hello_world_static.jinja2
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Hello World</title>
- <link rel="stylesheet" href="{{ request.static_url('static/app.css') }}"/>
+ <link rel="stylesheet" href="/static/app.css"/>
</head>
<body>
<h1>Hello {{ name }}!</h1>