开发者

"x of n" in StringTemplate from a single int/count

开发者 https://www.devze.com 2022-12-13 10:30 出处:网络
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?

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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消