Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
Add documentation for extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim Rowan committed Feb 14, 2013
1 parent 7e3b3f9 commit 01bf7e0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/DMS/Bundle/TwigExtensionBundle/Resources/doc/pad_string.md
@@ -0,0 +1,29 @@
# Pad String Extension

The pad string extension uses PHP's native str_pad function
to pad a string with a given character on the left, right or
both sides until the returned string reaches the specified
maximum length.

## Usage

This extension accepts three parameters; a pad character, an
integer specifying the maximum length of the returned string
and a string (optional) specifying which side to apply the
padding:

`{{ myString|padString('o', 4, 'STR_PAD_LEFT }}`
`{{ myString|padString('o', 4, 'STR_PAD_BOTH }}`
`{{ myString|padString('o', 4, 'STR_PAD_RIGHT }}`
`{{ myString|padString('o', 4 }}`

If myString contained the value 'ps', the output of the above
would be:

* oops
* opso
* psoo
* psoo

Where no third argument is provided, the filter defaults to
STR_PAD_RIGHT.

0 comments on commit 01bf7e0

Please sign in to comment.