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
10b55850
Commit
10b55850
authored
Feb 16, 2013
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make actually work for real, and with python3 support
parent
83ef69f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
pipeline/jinja2/ext.py
+5
-16
tests/tests/test_extension.py
+12
-2
No files found.
pipeline/jinja2/ext.py
View file @
10b55850
...
...
@@ -10,33 +10,22 @@ from pipeline.utils import guess_type
from
pipeline.templatetags.compressed
import
CompressedMixin
def
package_css
():
return
""
class
PipelineExtension
(
CompressedMixin
,
Extension
):
tags
=
set
([
'compressed_css'
,
'compressed_js'
])
def
parse
(
self
,
parser
):
package_name
=
None
stream
=
parser
.
stream
tag
=
stream
.
next
()
if
stream
.
current
.
test
(
'string'
):
if
stream
.
look
()
.
test
(
'string'
):
token
=
stream
.
next
()
package_name
=
token
.
value
else
:
package_name
=
parser
.
parse_expression
()
.
value
tag
=
next
(
parser
.
stream
)
package_name
=
parser
.
parse_expression
()
if
not
package_name
:
raise
TemplateSyntaxError
(
"Bad package name"
)
raise
TemplateSyntaxError
(
"Bad package name"
,
tag
.
lineno
)
args
=
[
package_name
]
if
tag
.
value
==
"compressed_css"
:
return
nodes
.
CallBlock
(
self
.
call_method
(
'package_css'
,
args
),
[],
[],
[])
return
nodes
.
CallBlock
(
self
.
call_method
(
'package_css'
,
args
),
[],
[],
[])
.
set_lineno
(
tag
.
lineno
)
if
tag
.
value
==
"compressed_js"
:
return
nodes
.
CallBlock
(
self
.
call_method
(
'package_js'
,
args
),
[],
[],
[])
return
nodes
.
CallBlock
(
self
.
call_method
(
'package_js'
,
args
),
[],
[],
[])
.
set_lineno
(
tag
.
lineno
)
return
[]
...
...
tests/tests/test_extension.py
View file @
10b55850
...
...
@@ -14,5 +14,15 @@ class ExtensionTest(TestCase):
PackageLoader
(
'pipeline'
,
'templates'
))
def
test_no_package
(
self
):
template
=
self
.
env
.
from_string
(
u"""{
%
compressed_css 'unknow'
%
}"""
)
self
.
assertEqual
(
u''
,
template
.
render
(
context
))
template
=
self
.
env
.
from_string
(
u"""{
%
compressed_css "unknow"
%
}"""
)
self
.
assertEqual
(
u''
,
template
.
render
())
template
=
self
.
env
.
from_string
(
u"""{
%
compressed_js "unknow"
%
}"""
)
self
.
assertEqual
(
u''
,
template
.
render
())
def
test_package_css
(
self
):
template
=
self
.
env
.
from_string
(
u"""{
%
compressed_css "screen"
%
}"""
)
self
.
assertEqual
(
u'<link href="/static/screen.css" rel="stylesheet" type="text/css" />'
,
template
.
render
())
def
test_package_js
(
self
):
template
=
self
.
env
.
from_string
(
u"""{
%
compressed_js "scripts"
%
}"""
)
self
.
assertEqual
(
u'<script type="text/css" src="/static/scripts.css" charset="utf-8"></script>'
,
template
.
render
())
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