Reputation: 913
I am using TT2. I want to print something[%0d]
from my template file. But i cannot seem to find any escape character for template toolkit usage.
Any suggestions as to how to skip %
and [
to be processed under TT
?
The exact line is:
printer.print_object(.name($sformatf("[% item %]_slv_agent_cfg[%0d]:", i)), .value([% item %]_slv_agent_cfg[i]));
Thanks in advance
Upvotes: 1
Views: 899
Reputation: 385897
You could use
[% "[%" %]
in lieu of
[%
It would look like this:
$ tpage <<<'slv_agent_cfg[% "[%" %]0d]'
slv_agent_cfg[%0d]
$ tpage <<<'slv_agent_cfg[% "[%0d]" %]'
slv_agent_cfg[%0d]
A shorter solution would be to use
[[%%]%
in lieu of
[%
It would look like this:
$ tpage <<<'slv_agent_cfg[[%%]%0d]'
slv_agent_cfg[%0d]
If you find yourself needing to escape too many instances, you could switch the tag style.
Finally, you could alter the program to avoid the sequence in the first place. For example, you might be able to replace
"slv_agent_cfg[%0d]"
with
"slv_agent_cfg[\%0d]"
or
{"slv_agent_cfg[","%0d]"}
I don't know Verilog, so the specifics may not be correct, but you get the idea.
Upvotes: 4
Reputation: 23091
If I'm using TT to write out a TT template, is there a good way to escape [% and %]?
So something[\%0d]
should work.
Upvotes: 0