Wrap strings with white space whitespace using stringtemplate
How can I overlay a sentence with a space so that it will be printed in the "block".
I want to print a receipt. for a given item, I want to print the quantity, item name and price.
12 x Example short name Β£2.00
1 x This is an example of
a long name Β£10.00
The "block" I am referring to is shown below.
12 x |Example short name | Β£2.00
1 x |This is an example of |
|a long name | Β£10.00
Using the example above, I can easily handle the quantity and price formatting. Using string formatting. Then for the element name, the best way to use it I think is to break up the element name in code and use the StringTemplate wrapper function, but I don't know how to wrap the rest of the line with a space
I am using .Net and StringTemplate 4. Here is a simplified version of the template I have. Assuming I have an item with Quantity, ItemName (split into an array of strings) and Price properties.
<item.Quantity; format="{0,4}"> x <item.ItemName; wrap, separator=" ", anchor><item.Price; format="Β£{0,8}">
Now, at the moment, the only way I can get it to work is by calculating the space in the code and adding it to the array of element names.
So, is there a neat way to do this in a StringTemplate?
source to share
No one has answered this question yet
Check out similar questions: