Format text in epp

10 views
Skip to first unread message

Helmut Schneider

unread,
Aug 1, 2018, 10:05:32 AM8/1/18
to puppet...@googlegroups.com
Hi,

is there a way to format text in epp? Something like

a 100
abc 20
defgds 30

Thank you!

<%- | Hash $postfixTransport
| -%>
# This file is managed by Puppet, don't edit it by hand.
# All changes will be overwritten!

<% if ($postfixTransport) { -%>
<% $postfixTransport.each |$domain, $target| { -%>
<%= $domain %> <%= $target %>
<% } -%>
<% } -%>

jcbollinger

unread,
Aug 1, 2018, 12:53:04 PM8/1/18
to Puppet Users
EPP has access to all operators, functions, and types available in the current Puppet environment, both built-in and module-provided.  Among Puppet's built-in functions is sprintf, which is a wrapper for Ruby's Kernel::sprintf, which in turn is inspired by C's sprintf.  It can perform the kind of formatting you're looking for, perhaps something like this:

<% $postfixTransport.each |$domain, $target| { -%>
<%= sprintf("%-10s %4d", $domain, $target) %>
<% } -%>


John

Helmut Schneider

unread,
Aug 2, 2018, 4:54:04 PM8/2/18
to puppet...@googlegroups.com
jcbollinger wrote:

> On Wednesday, August 1, 2018 at 5:05:32 AM UTC-5, Helmut Schneider
> wrote:
> >
> > Hi,
> >
> > is there a way to format text in epp? Something like
> >
> > a 100
> > abc 20
> > defgds 30
> >
> > Thank you!
> >
> > <%- | Hash $postfixTransport
> > | -%>
> > # This file is managed by Puppet, don't edit it by hand.
> > # All changes will be overwritten!
> >
> > <% if ($postfixTransport) { -%>
> > <% $postfixTransport.each |$domain, $target| { -%>
> > <%= $domain %> <%= $target %>
> > <% } -%>
> > <% } -%>
> >
> >
> EPP has access to all operators, functions, and types available in
> the current Puppet environment, both built-in and module-provided.
> Among Puppet's built-in functions is sprintf
> <https://puppet.com/docs/puppet/5.5/function.html#sprintf>, which is
> a wrapper for Ruby's Kernel::sprintf
> <https://apidock.com/ruby/Kernel/sprintf>, which in turn is inspired
> by C's sprintf. It can perform the kind of formatting you're looking
> for, perhaps something like this:
>
> <% $postfixTransport.each |$domain, $target| { -%>
> <%= sprintf("%-10s %4d", $domain, $target) %>
> <% } -%>

Thank you!

Reply all
Reply to author
Forward
0 new messages