Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
djnro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
djnro
Commits
c5a8714e
Commit
c5a8714e
authored
Nov 23, 2015
by
Zenon Mousmoulas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge template tags include_maybe, template_exists in one file: template_maybe.py
parent
f5557fe8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
edumanage/templatetags/template_exists.py
edumanage/templatetags/template_exists.py
+0
-13
edumanage/templatetags/template_maybe.py
edumanage/templatetags/template_maybe.py
+10
-0
No files found.
edumanage/templatetags/template_exists.py
deleted
100644 → 0
View file @
f5557fe8
from
django
import
template
from
django.template.defaultfilters
import
stringfilter
register
=
template
.
Library
()
@
register
.
filter
@
stringfilter
def
template_exists
(
value
):
try
:
template
.
loader
.
get_template
(
value
)
return
True
except
template
.
TemplateDoesNotExist
:
return
False
edumanage/templatetags/
includ
e_maybe.py
→
edumanage/templatetags/
templat
e_maybe.py
View file @
c5a8714e
from
django
import
template
from
django.template.defaultfilters
import
stringfilter
from
django.template.loader_tags
import
do_include
from
django.template.defaulttags
import
CommentNode
register
=
template
.
Library
()
@
register
.
filter
@
stringfilter
def
template_exists
(
value
):
try
:
template
.
loader
.
get_template
(
value
)
return
True
except
template
.
TemplateDoesNotExist
:
return
False
@
register
.
tag
(
'include_maybe'
)
def
do_include_maybe
(
parser
,
token
):
# Source: http://stackoverflow.com/a/18951166/15690
...
...
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