Dutchman Dutchman - 1 year ago 113
CSS Question

Send variable along within include block

I'm working on a personal Django project where my plan is to make some sort of function in my site in form of a CSS Marquee (scrolling text).

I was able to make an marquee.html file with the code from here, and use it on several pages on my site using {% include "marquee.html" %} blocks, but the displayed string in the marquee is within the html file itself (marquee.html) between < p >-tags

Is there any way to send a variable/string along with an {%include "" %} block that replaces/adds to the < p > tags at the end of the marquee code?


{% include "marquee.html" {{ stringToDisplay }} %}

Answer Source

The current context is available for the included template. You can use the "with" option to send any additional context.

 {% include "marquee.html" with message="Hello" %}

and in your marqueue.html template

<div>{{ message }}</div>


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download