Need help with filter in jinja2 in export template. #15208
-
Hi , I am getting following output on rack position
I only want to filter out '20' from the above output when in export template. tried to find jinja2 built in filter but could not find the appropritate output |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Hm, can you do Previously I used rsplit in my jinja2 template to achieve my goal of intepreting a subif as a VLAN value.
which gave me
|
Beta Was this translation helpful? Give feedback.
-
The
edit: removed section about normalize() because it doesn't do what I thought. |
Beta Was this translation helpful? Give feedback.
-
Hi @kyerlasswell , I have just tested on both nbshell and in jinja2
jinja2 also gave same output "'M1.2.1010'" |
Beta Was this translation helpful? Give feedback.
I was just saying python's
print()
gives you an example of the returned data, you shouldn't use that in the template.I just set up a simple test using export templates and I am having no problem with getting the device position in the format you're looking for. Again, the output that you get from nbshell,
Decimal('20')
, is just how the data is displayed - the actual returned data is the number alone.My entire code for this test is exactly as shown below. I would recommend setting up an identical test for yourself and using that as a starting place for troubleshooting.
d
is equal to the current device in the loop.