making a python dicitonary into java script object in jinja template

5 views
Skip to first unread message

J Henderson

unread,
Apr 4, 2019, 6:09:30 PM4/4/19
to pocoo-libs
Hello I'm am new to python and jinja templates and Java Script. I am attempting to pass a  nested dictionary via python to the jinja template. Once in the template I want convert my python dictionary into a Java Script object.
The error I am receiving is "identified or string literal or numeric literal expected". Any help would be appreciated.



Source code in template::

function GetItemValue() {
let share= {{shares|safe}}; //identified or string literal or numeric literal expected



Source code in python

share_data = {};
for shares in share.SHARES.getchildren():
thisid = shares.ID.text
# here I create the nested Dictionary for share details
data = {"MICR_Number":shares.MICR.text,
"UserCode":shares.TRCODE1.text,
"Current Max Courtesy Pay":shares.TRAMOUNT1.text,
"Original Choice of Courtesy Pay":shares.TRAMOUNT2.text}
share_data[thisid] = data
  template = self.get_template("index.html", {'shares':share_data})


Reply all
Reply to author
Forward
0 new messages