-
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
Showing
4 changed files
with
378 additions
and
130 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,23 @@ | ||
from django.template import Library, Node, TemplateSyntaxError | ||
from django.conf import settings | ||
|
||
register = Library() | ||
|
||
|
||
class GetSettings(Node): | ||
def __init__(self, varname): | ||
self.varname = varname | ||
|
||
def render(self, context): | ||
context[self.varname] = settings | ||
return '' | ||
|
||
|
||
@register.tag(name="get_settings") | ||
def get_settings(parser, token): | ||
bits = token.contents.split() | ||
if len(bits) != 3: | ||
raise TemplateSyntaxError("get_settings tag takes exactly 2 arguments") | ||
if bits[1] != 'as': | ||
raise TemplateSyntaxError("1st argument to get_settings tag must be 'as'") | ||
return GetSettings(bits[2]) |
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
Oops, something went wrong.