Skip to content

Commit

Permalink
Added in fles to get Djaml into the CheeseShop
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hartjes committed Mar 24, 2011
1 parent 20bdb5a commit c21906d
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.pyc
3 changes: 3 additions & 0 deletions build/lib/djaml/__init__.py
@@ -0,0 +1,3 @@
from loaders import haml_loaders as _loaders

locals().update(_loaders)
32 changes: 32 additions & 0 deletions build/lib/djaml/loaders.py
@@ -0,0 +1,32 @@
from django.template import TemplateDoesNotExist

from hamlpy import hamlpy

from utils import get_django_template_loaders

def get_haml_loader(loader):
if hasattr(loader, 'Loader'):
baseclass = loader.Loader
else:
class baseclass(object):
def load_template_source(self, *args, **kwargs):
return loader.load_template_source(*args, **kwargs)

class Loader(baseclass):
def load_template_source(self, template_name, *args, **kwargs):
if not template_name.endswith('.haml'):
raise TemplateDoesNotExist(template_name)

haml_source, template_path = super(Loader, self).load_template_source(template_name, *args, **kwargs)
hamlParser = hamlpy.Compiler()
html = hamlParser.process(haml_source)

return html, template_path

load_template_source.is_usable = True

return Loader

haml_loaders = dict((name, get_haml_loader(loader))
for (name, loader) in get_django_template_loaders())

25 changes: 25 additions & 0 deletions build/lib/djaml/utils.py
@@ -0,0 +1,25 @@
import imp
from os import listdir
from os.path import dirname, splitext

from django.template import loaders

MODULE_EXTENSIONS = tuple([suffix[0] for suffix in imp.get_suffixes()])

def get_django_template_loaders():
return [(loader.__name__.rsplit('.',1)[1], loader)
for loader in get_submodules(loaders)
if hasattr(loader, 'load_template_source')]

def get_submodules(package):
submodules = ("%s.%s" % (package.__name__, module)
for module in package_contents(package))
return [__import__(module, {}, {}, [module.rsplit(".", 1)[-1]])
for module in submodules]

def package_contents(package):
package_path = dirname(loaders.__file__)
contents = set([splitext(module)[0]
for module in listdir(package_path)
if module.endswith(MODULE_EXTENSIONS)])
return contents
Binary file added dist/djaml-1.0-py2.7.egg
Binary file not shown.
Binary file added dist/djaml-1.0.macosx-10.4-x86_64.tar.gz
Binary file not shown.
Binary file added dist/djaml-1.0.tar.gz
Binary file not shown.
20 changes: 20 additions & 0 deletions djaml.egg-info/PKG-INFO
@@ -0,0 +1,20 @@
Metadata-Version: 1.0
Name: djaml
Version: 1.0
Summary: A Django template loader for loading and converting HamlPy markup to HTML
Home-page: http://github.com/chartjes/djaml/
Author: Chris Hartjes
Author-email: UNKNOWN
License: MIT
Description:
Djaml is a template loader for Django that allows you to use HamlPy for markup.

Keywords: django haml hamlpy
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Utilities
8 changes: 8 additions & 0 deletions djaml.egg-info/SOURCES.txt
@@ -0,0 +1,8 @@
setup.py
djaml/__init__.py
djaml/loaders.py
djaml/utils.py
djaml.egg-info/PKG-INFO
djaml.egg-info/SOURCES.txt
djaml.egg-info/dependency_links.txt
djaml.egg-info/top_level.txt
1 change: 1 addition & 0 deletions djaml.egg-info/dependency_links.txt
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions djaml.egg-info/top_level.txt
@@ -0,0 +1 @@
djaml

1 comment on commit c21906d

@Chris2048
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the /build/lib/djaml files, and why do they differ from the stuff in /djaml?

Please sign in to comment.