Field length formatting

Kjeld <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hello, 

I am new to Freemarker and I am trying to output a value in a predefined
length format, in particular have Freemarker add trailing spaces to meet a
specified string length. E.g. value 'Foo' should become '            Foo'
when specifying a length of 15. 

Does Freemarker provide in such a method/function?

I was able to create a macro that does the trick, but I am curious if such a
function exists already in the framework.

<#macro format size><#local nestedContent><#nested></#local><#if size gt
nestedContent?length><#list 1..size - nestedContent?length as n>
</#list><#nested><#else><#nested></#if></#macro>

Usage: <@format size=15>Foo</@format>

Thanks,
Kjeld 
-- 
View this message in context: http://freemarker.624813.n4.nabble.com/Field-length-formatting-tp2065230p2065230.html
Sent from the freemarker-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.