0

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)

1
  • Can you put add details (input data, desired output, etc) ? Dec 9, 2009 at 9:55

1 Answer 1

0

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

1
  • 1
    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
    Dec 10, 2009 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.