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
77310c1b
Commit
77310c1b
authored
Feb 02, 2013
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove jinja2 support temporarily
parent
eb9e7e5d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
112 deletions
+0
-112
pipeline/jinja2/__init__.py
+0
-0
pipeline/jinja2/ext.py
+0
-112
No files found.
pipeline/jinja2/__init__.py
deleted
100644 → 0
View file @
eb9e7e5d
pipeline/jinja2/ext.py
deleted
100644 → 0
View file @
eb9e7e5d
from
__future__
import
unicode_literals
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.conf
import
settings
from
jinja2
import
Environment
,
FileSystemLoader
from
pipeline.packager
import
Packager
,
PackageNotFound
from
pipeline.utils
import
guess_type
class
Jinja2Compressed
(
object
):
def
__init__
(
self
,
package_type
):
from
django.template.loaders
import
app_directories
if
package_type
not
in
[
'css'
,
'js'
]:
raise
PackageNotFound
(
"Package type must be css or js, supplied
%
s"
%
package_type
)
self
.
package_type
=
package_type
self
.
loader
=
FileSystemLoader
((
app_directories
.
app_template_dirs
+
settings
.
TEMPLATE_DIRS
))
def
get_package
(
self
,
name
):
"""Get the js or css package."""
package
=
{
'js'
:
settings
.
PIPELINE_JS
.
get
(
name
,
{}),
'css'
:
settings
.
PIPELINE_CSS
.
get
(
name
,
{}),
}[
self
.
package_type
]
if
package
:
package
=
{
name
:
package
}
self
.
packager
=
{
'js'
:
Packager
(
css_packages
=
{},
js_packages
=
package
),
'css'
:
Packager
(
css_packages
=
package
,
js_packages
=
{}),
}[
self
.
package_type
]
try
:
self
.
package
=
self
.
packager
.
package_for
(
self
.
package_type
,
name
)
except
PackageNotFound
:
self
.
package
=
None
def
render
(
self
,
path
):
"""Render the HTML tag."""
if
not
self
.
package
.
template_name
:
template_name
=
{
'js'
:
'pipeline/js.jinja'
,
'css'
:
'pipeline/css.jinja'
,
}[
self
.
package_type
]
else
:
template_name
=
self
.
package
.
template_name
mimetype
=
{
'js'
:
'text/javascript'
,
'css'
:
'text/css'
,
}[
self
.
package_type
]
context
=
self
.
package
.
extra_context
context
.
update
({
'type'
:
guess_type
(
path
,
mimetype
),
'url'
:
staticfiles_storage
.
url
(
path
)
})
env
=
Environment
(
loader
=
self
.
loader
)
tpl
=
env
.
get_template
(
template_name
)
return
tpl
.
render
(
**
context
)
def
html
(
self
,
name
):
"""Render the HTML Snippet"""
self
.
get_package
(
name
)
if
self
.
package
:
if
not
settings
.
DEBUG
:
return
self
.
render
(
self
.
package
.
output_filename
)
else
:
paths
=
self
.
packager
.
compile
(
self
.
package
.
paths
)
templates
=
self
.
packager
.
pack_templates
(
self
.
package
)
return
{
'css'
:
self
.
render_individual_css
(
paths
),
'js'
:
self
.
render_individual_js
(
paths
,
templates
)
}[
self
.
package_type
]
else
:
return
''
# don't return anything if no package found
def
render_individual_css
(
self
,
paths
):
"""Render individual CSS files"""
tags
=
[
self
.
render
(
path
)
for
path
in
paths
]
return
'
\n
'
.
join
(
tags
)
def
render_individual_js
(
self
,
paths
,
templates
=
None
):
"""Render individual JS files"""
tags
=
[
self
.
render
(
path
)
for
path
in
paths
]
if
templates
:
tags
.
append
(
self
.
render_inline_js
(
self
.
package
,
templates
))
return
'
\n
'
.
join
(
tags
)
def
render_inline_js
(
self
,
package
,
js
):
template_name
=
(
self
.
package
.
template_name
or
"pipeline/inline_js.jinja"
)
context
=
self
.
package
.
extra_context
context
.
update
({
'source'
:
js
})
env
=
Environment
(
loader
=
self
.
loader
)
tpl
=
env
.
get_template
(
template_name
)
return
tpl
.
render
(
**
context
)
def
compressed_css
(
package_name
):
compress
=
Jinja2Compressed
(
'css'
)
return
compress
.
html
(
package_name
)
def
compressed_js
(
package_name
):
compress
=
Jinja2Compressed
(
'js'
)
return
compress
.
html
(
package_name
)
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