views:

72

answers:

1

I'm trying to print out generate shipping labels, and I know how many I want. So given that I know n, how do I print "x of n" for x=1 to n?

What I'm wanting to do is have an expansion template that will take n and provide the x and n variables to the template I shall pass (StringTemplate is a functional-type templating language, so this sort of thing is it's strength).

Sorry about not having a structure yet, but I'm just having thinking inside the framework...

Basically, given :

$xOfn(n=3)$

I should get

1 of 3
2 of 3
3 of 3

The real template that I'd like to use is something like

<div class="label">
   <div class="labelInfo">$info$</div>
   <div class="item">$x$ of $n$</div>
</div>

Where I would use something like $xOfn(n=someInt,template="myTemplate")$ (the above template is called myTemplate)

A: 

Hi. How about $objects:{ o | $i$ of $length(objects)$}$

Ter

Terence Parr
There are plenty of examples of this on the site... but I do not have a collection - I have an integer (that I want to do a list expansion on). Consider also the case where you have an article that is 4 pages long, and you are on page 2 - how would you go about formatting the page links along with previous and next?
Stephen