Skip to content

Create Django templatetags #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/django_idom/static/js/idom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Build.js is going to need to be moved here via your deployment scripts
// This will allow developers to import IDOM the Django way
2 changes: 2 additions & 0 deletions src/django_idom/templates/idom/head_content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- The importable IDOM JS -->
<script src="{% static 'js/idom.js' %}" crossorigin="anonymous"></script>
4 changes: 4 additions & 0 deletions src/django_idom/templates/idom/root.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- Allows for making the IDOM root object the Django way
Developers will often opt not to use this,
but having this makes getting started a little bit easier to explain -->
<div id="{{ html_id }}"></div>
Empty file.
16 changes: 16 additions & 0 deletions src/django_idom/templatetags/idom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django import template


register = template.Library()


# Template tag that renders the IDOM scripts
@register.inclusion_tag("idom/head_content.html")
def idom_scripts():
pass


# Template tag that renders an empty idom root object
@register.inclusion_tag("idom/root.html")
def idom_view(html_id):
return {"html_id": html_id}