Menu
©2015
Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2015-1-16 18:32

Module puredom.text

  • A collection of text utilities and a way to apply them as filters.

  • Defined in: utils.js
Module Summary
Constructor Attributes Constructor Name and Description
 
puredom.text(str, A)
When called as a function, puredom.text() acts as an alias of puredom.text.filter.

Method Summary

Method Attributes Method Name and Description
<static>  
puredom.text. dateformat (str, type)
Format a date using whatever i18n module is registered with puredom.
<static>  
puredom.text. escape (str)
URL-encode a string.
<static>  
puredom.text. filter (str, filters)
Modify a string using a filter to apply any functions available in puredom#text.
<static>  
puredom.text. htmlEntities (str)
Convert special characters to their HTML-encoded equivalents.
<static>  
puredom.text. nl2br (str)
Convert newline characters to HTML
elements.
<static>  
puredom.text. numbersOnly (str)
Strip all non-numeric characters from a string.
<static>  
puredom.text. trim (str)
Fast JS trim implementation across all browsers.
<static>  
puredom.text. truncate (str, maxLen, byWord, indicatorChars)
Truncate a string, optionally on word boundaries.
<static>  
puredom.text. ucFirst (str)
Convert the first character of the first word to uppercase.
<static>  
puredom.text. ucWords (str)
Convert the first character of each word to uppercase.
<static>  
puredom.text. unescape (str)
URL-decode a string.

Module Detail

puredom.text(str, A)
When called as a function, puredom.text() acts as an alias of puredom.text.filter.
Parameters:
{String} str
The string to modify
{String|Array} A
pipe-separated String or Array, where each value is a filter. Arguments to a filter can be passed using a colon followed by a CSV of the arguments.
Returns:
{String} The modified string

Method Detail

  • <static> {String} puredom.text.dateformat(str, type)
    Format a date using whatever i18n module is registered with puredom.
    Note: Requires a conversion function to be registered as puredom.i18n() in order to convert dates.
    Parameters:
    {String} str
    The string to modify
    {String} type Optional, Default: date
    A date type to pass to i18n. Defaults to "date".
    Returns:
    {String} The formatted date string
    Requires:
    puredom.i18n
  • <static> {String} puredom.text.escape(str)
    URL-encode a string. (using encodeURIComponent)
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.filter(str, filters)
    Modify a string using a filter to apply any functions available in puredom#text.
    puredom.text.filter("  ", 'trim|ucWords|htmlEntities') === "<Hi There!>";
    puredom.text("This string might be too long!", 'truncate:10,byWord') === "This string...";
    Parameters:
    {String} str
    The string to modify
    {String|Array} filters
    A bar-separated string or {Array}, where each value is a filter. Arguments to a filter can be passed using a colon followed by a CSV of the arguments.
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.htmlEntities(str)
    Convert special characters to their HTML-encoded equivalents.
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.nl2br(str)
    Convert newline characters to HTML
    elements.
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.numbersOnly(str)
    Strip all non-numeric characters from a string.
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.trim(str)
    Fast JS trim implementation across all browsers.
    Note: Research credit goes to http://blog.stevenlevithan.com/archives/faster-trim-javascript
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.truncate(str, maxLen, byWord, indicatorChars)
    Truncate a string, optionally on word boundaries.
    Optionally adds a textual truncation indicator (eg: "...").
    Parameters:
    {String} str
    The string to truncate
    {Number} maxLen Optional, Default: 80
    Maximum string length, in characters.
    {Boolean|String} byWord Optional, Default: false
    Don't truncate in the middle of words. Resultant string may be shorter if set to true.
    {String} indicatorChars Optional, Default: "..."
    Custom indicator characters if truncation occurs. Defaults to "...".
    Returns:
    {String} The truncated string
  • <static> {String} puredom.text.ucFirst(str)
    Convert the first character of the first word to uppercase.
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.ucWords(str)
    Convert the first character of each word to uppercase.
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string
  • <static> {String} puredom.text.unescape(str)
    URL-decode a string. (using decodeURIComponent)
    Parameters:
    {String} str
    The string to modify
    Returns:
    {String} The modified string