helper.format.html 3.82 KB
<!--/*

  ADOBE CONFIDENTIAL
  __________________

   Copyright 2015 Adobe Systems Incorporated
   All Rights Reserved.

  NOTICE:  All information contained herein is, and remains
  the property of Adobe Systems Incorporated and its suppliers,
  if any.  The intellectual and technical concepts contained
  herein are proprietary to Adobe Systems Incorporated and its
  suppliers and are protected by trade secret or copyright law.
  Dissemination of this information or reproduction of this material
  is strictly forbidden unless prior written permission is obtained
  from Adobe Systems Incorporated.

*/-->

<!--/*
    Format the date.

    @param {Date}   [date]       The date to format (default to the current date)
    @param {String} [dateFormat] The format to use
*/-->
<template data-sly-template.date="${ @ datetime, dateFormat }">
    <sly data-sly-use.date="${'/libs/screens/dcc/components/helper.format.date.js' @ date=datetime, dateFormat=dateFormat}">${date.formattedDate}</sly>
</template>

<!--/*
    Format the date and time.

    @param {Date}   [datetime]   The datetime to format (default to the current date and time)
    @param {String} [dateFormat] The format to use
*/-->
<template data-sly-template.datetime="${ @ datetime, class }">
    <foundation-time type="datetime" class="${class}" value="${datetime.toInstant.toStringĀ @ context='attribute'}"/>
</template>

<!--/*
    Format a duration.

    @param {Date}   [interval] The time interval
*/-->
<template data-sly-template.duration="${ @ interval }">
    <sly data-sly-use.date="${'/libs/screens/dcc/components/helper.format.date.js' @ date=interval }">${date.formattedDuration}</sly>
</template>

<!--/*
    Format the resolution.

    @param {String}         [resolution] The resolution to format
    @param {String|Integer} [width]      The width to use as a fallback
    @param {String|Integer} [height]     The height to use as a fallback
    @param {String}         [unit]       The unit for the dimension
*/-->
<template data-sly-template.resolution="${ @ resolution, width, height, unit}">
    <sly data-sly-use.dimension="${'/libs/screens/dcc/components/helper.format.dimension.js' @ value=resolution, valueArray=width && height && [width, height], delimiter='x'}">
        <sly data-sly-test.resolution="${dimension.formattedDimension}">
            <span itemprop="width">
                ${resolution.width}
                <span data-sly-test="${unit}" class="u-coral-screenReaderOnly">
                    ${unit @ i18n, hint='unit for the dimension (i.e. pixels, inches, etc.)', locale=request.locale}
                </span>
            </span>
            ${' x ' @ i18n, hint='Separator used to format the resolution (i.e. width x height)', locale=request.locale}
            <span itemprop="height">
                ${resolution.height}
                <span data-sly-test="${unit}" class="u-coral-screenReaderOnly">
                    ${unit @ i18n, hint='unit for the dimension (i.e. pixels, inches, etc.)', locale=request.locale}
                </span>
            </span>
        </sly>
    </sly>
</template>

<!--/*
    Shorten the specified long string.

    @param {String}  string      The string to shorten
    @param {Integer} [threshold] If the string elements are longer than this value, they will be truncated
    @param {Integer} [keep]      Number of characters to keep (start and end) in the shortened string elements
    @param {String}  [remove]    A substring to remove from the string
    @param {String}  [delimiter] The delimiter to use when truncating
*/-->
<template data-sly-template.shortstring="${ @ string, threshold, keep, remove, delimiter }">
    <sly data-sly-use.stringHelper="${'/libs/screens/dcc/components/helper.format.longstring.js' @ value=string, threshold=threshold, keep=keep, remove=remove, delimiter=delimiter}">${stringHelper.shortenedString}</sly>
</template>