-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3898f6
commit 28c4c5c
Showing
16 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from django import template | ||
register = template.Library() | ||
|
||
ICONS = { | ||
'movers': 'mover', | ||
'decorators': 'decorator', | ||
'insurance': 'insurance', | ||
'landscaping': 'lawn', | ||
'post offices': 'postal', | ||
'telcos': 'telephone', | ||
'banks': 'bank', | ||
'dry cleaners': 'dry cleaner', | ||
'grocery stores': 'grocery', | ||
'schools': 'school', | ||
'day cares': 'day care', | ||
'churches': 'church', | ||
'gas stations': 'gas station', | ||
'hospitals': 'hospital', | ||
'mechanics': 'mechanic', | ||
'restaurants': 'restaurant', | ||
'shopping': 'plaza', | ||
'hair dressers': 'hair', | ||
'pharmacy': 'pharmacy', | ||
} | ||
|
||
def do_icon(parser, token): | ||
try: | ||
# split_contents() knows not to split quoted strings. | ||
tag_name, category = token.split_contents() | ||
except ValueError: | ||
raise template.TemplateSyntaxError("%r tag requires three arguments (Service Date, Departure Start Date, Departure End Date)" % token.contents.split()[0]) | ||
return Icon(category) | ||
|
||
class Icon(template.Node): | ||
def __init__(self, category): | ||
self.category = template.Variable(category) | ||
|
||
def render(self, context): | ||
category = self.category.resolve(context) | ||
|
||
return ICONS.get(category) | ||
|
||
register.tag('icon', do_icon) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.