App-Dapper
view release on metacpan or search on metacpan
Results:
```
MARK BENSON PORTFOLIO
My very long page title...
```
Here is a list of filters that are provided by default. Most are provided by
Template::Alloy. Others that are provided by Dapper are marked as [DSF].
*Text*
The following methods can be called on text/string variables.
Filter | Description
---------------------|-----------------------------------------------------------------------
`abs` | Returns the absolute value
`atan2(x)` | Returns the arctangent. The item itself represents Y, the passed argument represents X.
`chunk(n)` | Split string up into a list of chunks of text n chars wide.
`collapse` | Strip leading and trailing whitespace and collapse all other space to one space.
`cos` | Returns the cosine of the item.
`date_to_xmlschema` | [DSF] Convert a date to an XML-formatted version of the date that also includes the timezone
`defined` | Always true - because the undef sub translates all undefs to ''.
`eval` | Process the string as though it was a template.
`evaltt` | Same as the eval filter.
`exp` | Returns "e" to the power of the item.
`fmt` | Similar to format. Returns a string formatted with the passed pattern. Default pattern is %s. Opposite from of the sprintf vmethod.
`format` | Print the string out in the specified format. It is similar to the "fmt" virtual method, except that the item is split on newline and each line is processed separately.
`hash` | Returns a one item hash with a key of "value" and a value of the item.
`hex` | Returns the decimal value of the passed hex numbers.
`html` | Performs a very basic html encoding (swaps out `&`, `<`, `>` and `"` with the corresponding html entities).
`indent(n)` | Indent by `n` spaces if an integer is passed (default is 4), or string if string is passed.
`int` | Return the integer portion of the value (0 if none).
`json(1)` | Returns a JSON encoded representation. Returns a pretty JSON encoded representation if `1` is passed.
`json` | [DSF] Convert an object or string to a JSON representation
`lc` | Same as the lower vmethod. Returns the lowercased version of the item.
`lcfirst` | Lowercase the leading letter.
`length` | Return the length of the string.
`list` | Returns a list (arrayref) with a single value of the item.
`log` | Returns the natural log base "e" of the item.
`lower` | Return the string lowercased.
`match(p, 1)` | Return a list of items matching the regular expression pattern `p`. If the second argument is `1`, match globally.
`none` | Returns the item without modification.
`null` | Return nothing.
`oct` | Returns the decimal value of the octal string.
`rand` | Returns a number greater or equal to 0 but less than the value of the item.
`remove(p)` | Same as replace, but is global and replaces the regular expression `p` with nothing.
`repeat(n, s)` | Repeat the item `n` times, separated with `s`. `s` is optional.
`replace(p, q)` | Globally replace all `p` with `q`. `p` and `q` may be strings or regular expressions. An optional third argument of `0` may be passed to turn off global replacement.
`replace_last` | [DSF] Replace the last occurrance of a string with another string
`return` | Returns the item from the inner most block, macro, or file. Similar to the `return` directive.
`search(s)` | Tests if the given pattern is in the string.
`sin` | Returns the sine of the item.
`size` | Always returns 1 for text variables.
`smart` | [DSF] Replace dashes with mdashes and ndashes
`split(s, n)` | Splits the item on regular expression `s` and returns an array with the chunks. If `n` is passed, processing stops after the first `n` chunks.
`sprintf(p, q, ...)` | Uses the pattern stored in self, and passes it to sprintf with the passed arguments. Opposite from the fmt vmethod.
`sqrt` | Returns the square root of the number.
`srand` | Calls the perl srand function to set the internal random seed. This will affect future calls to the rand vmethod.
`stderr` | Print the item to the current STDERR handle.
`substr(i, n)` | Returns a substring of item starting at `i` and going to the end of the string. If `n` is passed, the substring stops after `n` characters.
`trim` | Strips leading and trailing whitespace.
`uc` | Same as the upper command. Returns uppercased string.
`ucfirst` | Uppercase the leading letter.
`upper` | Return the string uppercased.
`uri` | Perform a very basic URI encoding.
`url` | Perform a URI encoding - but some characters such as `:` and `/` are left intact.
`xml_escape` | [DSF] Escape strings that may contain XML so the string can be included in XML files such as ATOM or RSS feeds
`xml` | Performs a very basic xml encoding (swaps out `&`, `<`, `>`, `'` and `"` with the corresponding xml entities).
*List*
The following methods can be called on arrays (text/strings are automatically
converted to an array containing a single element containing the value of the
text/string).
Filter | Description
---------------------|-----------------------------------------------------------------------
`fmt(s,t,u)` | Returns a string of the values of the list formatted with the passed pattern and joined with the passed string. Default pattern is %s and the default join string is space.
`first(n)` | Returns a list of the first `n` items in the list.
`grep(s)` | Returns a list of all items matching the regex pattern.
`hash` | Returns a hash with the array indexes as keys and the values as values.
`join(s)` | Joins on `s`. `s` defaults to space.
`json(1)` | Returns a JSON encoded representation. If `1` is passed, returns a JSON-encoded pretty representation.
`last(n)` | Returns a list of the last `n` items in the list.
`list` | Returns a reference to the list.
`map` | `[% mylist.map(->{ this.upper }) %]` Returns a list with the macro played on each item.
`max` | Returns the last item in the array.
`merge(a)` | Returns a new list with all defined items from list `a` added.
`nsort(key)` | Returns the numerically sorted items of the list. If the items are hashes, a key containing the field to sort on can be passed.
`pop` | Removes and returns the last element from the arrayref (the stash is modified).
`push(e)` | Adds an element to the end of the arrayref (the stash is modified).
`pick(n)` | Returns `n` random items from the list. `n` defaults to `1`.
`return` | Returns the list from the inner most block, macro, or file. Similar to the RETURN directive.
`reverse` | Returns the list in reverse order.
`shift` | Removes and returns the first element of the arrayref (the stash is modified).
`size` | Returns the number of elements in the array.
`slice(i,n)` | Returns a list from the arrayref beginning at index `i` and continuing for `n` items.
`sort` | Returns the alphabetically sorted items of the list. If the items are hashrefs, a key containing the field to sort on can be passed.
`splice(i,n)` | Removes items from array beginning at `i` and continuing for `n` items.
`unique` | Return a list of the unique items in the array.
`unshift(n)` | Adds an item to the beginning of the arrayref.
*Hash*
The following methods can be called on hash type data structures. Additionally,
list virtual methods can be accessed via the Hash Virtual Object.
Filter | Description
---------------------|-----------------------------------------------------------------------
`fmt` | `[% myhash.fmt('%s => %s', "\n") %]` Passed a pattern and an string to join on. Returns a string of the key/value pairs of the hash formatted with the passed pattern and joined with the passed string. Default pattern is "%s\t%s...
`defined(a)` | Checks if `a` is defined in the hash.
`delete(a)` | Deletes the item `a` from the hash.
`each` | Turns the contents of the hash into a list - subject to change.
`exists(a)` | Checks if `a` is in the hash.
`hash` | Returns a reference to the hash.
`import(h)` | Overlays the keys of hash `h` over the keys of the hash item.
`item(k)` | Returns the hash value for key `k`.
`items` | Returns a list of the key and values (flattened hash).
`json(1)` | Returns a JSON encoded representation. If `1` is passed, returns a pretty JSON-encoded representation.
( run in 1.994 second using v1.01-cache-2.11-cpan-39bf76dae61 )