Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
bbc0a4e1
Commit
bbc0a4e1
authored
Dec 23, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more work
parent
ed80ec87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
pipeline/jinja2/ext.py
+47
-0
No files found.
pipeline/jinja2/ext.py
View file @
bbc0a4e1
...
...
@@ -3,11 +3,58 @@ try:
except
ImportError
:
from
django.contrib.staticfiles.storage
import
staticfiles_storage
# noqa
from
jinja2
import
nodes
from
jinja2.ext
import
Extension
from
pipeline.conf
import
settings
from
pipeline.packager
import
Packager
,
PackageNotFound
class
PipelineExtension
(
Extension
):
tags
=
set
([
'compressed_css'
,
'compressed_js'
])
def
parse
(
self
,
parser
):
stream
=
parser
.
stream
tag
=
stream
.
next
()
if
stream
.
current
.
test
(
'string'
):
if
stream
.
look
()
.
test
(
'string'
):
token
=
stream
.
next
()
package_name
=
nodes
.
Const
(
token
.
value
,
lineno
=
token
.
lineno
)
else
:
package_name
=
parser
.
parse_expression
()
if
tag
.
value
==
"compressed_css"
:
return
self
.
package_css
(
package_name
)
if
tag
.
value
==
"compressed_js"
:
return
self
.
package_js
(
package_name
)
return
[]
def
package_css
(
self
,
package_name
):
package
=
settings
.
PIPELINE_CSS
.
get
(
package_name
,
{})
if
package
:
package
=
{
package_name
:
package
}
packager
=
Packager
(
css_packages
=
package
,
js_packages
=
{})
try
:
package
=
packager
.
package_for
(
'css'
,
package_name
)
except
PackageNotFound
:
return
''
# fail silently, do not return anything if an invalid group is specified
if
settings
.
PIPELINE
:
return
self
.
render_css
(
package
,
package
.
output_filename
)
else
:
paths
=
packager
.
compile
(
package
.
paths
)
return
self
.
render_individual
(
package
,
paths
)
def
render_css
(
self
,
package
,
path
):
print
"render"
return
def
render_individual
(
self
,
package
,
paths
):
print
"render"
return
def
package_js
(
self
,
package_name
):
return
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment