Skip to content

Using a top level variable in datatable template #62

@kkostenko

Description

@kkostenko

Hello!

I am wondering if somebody knows an answer to the following question. I have a template 'top_level.html' which calls a table tag to render a datatable. I have a variable in that template and I want to use it in a datatable template 'share_table.html' similar to https://github.com/shymonk/django-datatable/blob/master/table/templates/table/table.html . How would I do it? If I simply use {{ some_variable }} in share_table.html it does not work.

=== top_level.html

{{ some_variable }}
{% render_share_table table %}

== table_tags.py

class ShareTableNode(TableNode):
template_name = "share_table.html" <-- need to use {{ some_variable }} here

@register.tag
def render_share_table(parser, token):
try:
tag, table = token.split_contents()
except ValueError:
msg = '%r tag requires a single arguments' % token.split_contents()[0]
raise template.TemplateSyntaxError(msg)
return ShareTableNode(table)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions