I have a numpy record array with 2 values per slot in the array.The name and offset, I want to display both of these values side by side using a Django template.
Python code
import numpy as np
from django.template import Template, Context, loader
from django.conf import settings
dtype={
'names' : ('name','offset'),
'formats' : ('U20','U20')}
instance= np.zeros(3,dtype)
instance[0]=('xga_control_reg','008')
instance[1]=('i_cmd_REG','012')
instance[2]=('i_ee_cmd_reg','016')
t=Template(The Django Template below)
c=Context({"instance":instance['name'],"instance":instance['offset']})
print(t.render(c))
Django Template
--
-- generated with parser version 1.09
--
library ieee;
use ieee.std_logic_1164.all;
package regfile
(
{% for name in instance%}
Name is {{name}} "{{name}}"
{%endfor%}
).""")
Current output
--
-- generated with parser version 1.09
--
library ieee;
use ieee.std_logic_1164.all;
package regfile
(
Name is 008 "008"
Name is 012 "012"
Name is 016 "016"
).
Desired Output
--
-- generated with parser version 1.09
--
library ieee;
use ieee.std_logic_1164.all;
package regfile
(
Name is xga_control_reg "008"
Name is i_cmd_REG "012"
Name is i_ee_cmd_reg "016"
).
I need to be able to display 2 values on the same line using the tag for loop in a Django template. If this can be done with 2 separate arrays instead of a numpy record array, that would be acceptable. Thank you!
import numpy as np
from django.template import Template, Context, loader
from django.conf import settings
dtype={
'names' : ('name','offset'),
'formats' : ('U20','U20')}
instance= np.zeros(3,dtype)
instance[0]=('xga_control_reg','008')
instance[1]=('i_cmd_REG','012')
instance[2]=('i_ee_cmd_reg','016')
t=Template(The Django Template below)
c=Context({"instance":instance})
print(t.render(c))
--
-- generated with parser version 1.09
--
library ieee;
use ieee.std_logic_1164.all;
package regfile
(
{% for i in instance%}
Name is {{i.0}} "{{i.1}}"
{%endfor%}
).""")