I have created a custom template tag that fetches the name and roll number of a student based on their ID.
@register.inclusion_tag('snippet/student_name.html')
def st_name_tag(profile, disp_roll=True, disp_name=True):
#performing some calculations
return {'full_name':student.name,
'roll':student.roll_number,
}
The included template file contains HTML code written in a single line to prevent any issues with JS error messages like unterminated string literal
.
My goal is to use the st_name_tag
within a JavaScript function.
This is my JS function:
{% load profile_tag %}
<script type = "text/javascript">
eventclick : function(st){
var div = ('<div></div>');
var st_id = st.id;
if (st.status == 'pass'){
div.append('<p>Student Name:{% st_name_tag '+st_id+' %}</p>');
}
}
I have attempted different variations of the approach, such as removing the +
and ''
signs from the st_id
variable without success. Any assistance would be greatly appreciated!