Skip to content

Commit e4f79e6

Browse files
committed
First release
1 parent 8e3c78e commit e4f79e6

File tree

11 files changed

+101
-0
lines changed

11 files changed

+101
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ docs/_build/
5555

5656
# PyBuilder
5757
target/
58+
59+
# Editors and IDEs
60+
.ropeproject/

LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LICENSE

MANIFEST

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# file GENERATED by distutils, do NOT edit
2+
setup.cfg
3+
setup.py
4+
webpack_loader/__init__.py
5+
webpack_loader/utils.py
6+
webpack_loader/templatetags/__init__.py
7+
webpack_loader/templatetags/webpack_loader.py

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
description-file = README.md

setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from distutils.core import setup
2+
setup(
3+
name = 'django-webpack-loader',
4+
packages = ['webpack_loader', 'webpack_loader/templatetags'], # this must be the same as the name above
5+
version = '0.0.1',
6+
description = 'Load your webpack bundles and chunks in django',
7+
author = 'Owais Lone',
8+
author_email = '[email protected]',
9+
url = 'https://github.com/owais/django-webpack-loader', # use the URL to the github repo
10+
keywords = ['django', 'webpack', 'assets'], # arbitrary keywords
11+
classifiers = [],
12+
)

webpack_loader/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
default_app_config = 'webpack_loader.apps.WebpackLoaderConfig'
2+
3+
from .utils import get_bundle

webpack_loader/apps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.apps import AppConfig
2+
3+
4+
class WebpackLoaderConfig(AppConfig):
5+
name = 'webpack_loader'
6+
verbose_name = "Webpack Loader"
7+
8+
def ready(self):
9+
from .signals import *

webpack_loader/signals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# will hook into collectstatic

webpack_loader/templatetags/__init__.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import datetime
2+
from django import template
3+
4+
from ..utils import get_bundle
5+
6+
7+
register = template.Library()
8+
9+
10+
@register.simple_tag
11+
def render_bundle(bundle_name):
12+
bundle = get_bundle(bundle_name)
13+
tags = []
14+
for chunk in bundle:
15+
if chunk['name'].endswith('.js'):
16+
tags.append('<script type="text/javascript" src="{}"/>'.format(chunk['publicPath']))
17+
elif chunk['name'].endwith('.css'):
18+
tags.append('<link type="text/css" href="{}" rel="stylesheet"/>'.format(chunk['publicPath']))
19+
return '\n'.join(tags)

0 commit comments

Comments
 (0)