Socket
Book a DemoInstallSign in
Socket

expressions

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expressions

Grab bag of template binding expressions.

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

expressions

Grab bag of template-binding expressions.

For use with new template-binding standards.

API

  • json
  • log
  • slice
  • keys
  • values
  • keyValue
  • date
  • fromNow
  • calendar

json

Convert to pretty-printed json output.

Usage:

{{data | json}}

log

Log to console before returning input.

Very useful for debugging.

Usage:

{{data | log}}
{{data | log('my data %s')}}
{{data | log('my data %s, %d', otherdata)}}

slice

Slice an array of data.

Usage:

{{items | slice}}
{{items | slice(2)}}
{{items | slice(2, 5)}}

keys

Get array of keys from an Object.

Usage:

<template repeat="{{key in items | keys}}">
 {{key}}
</template>

values

Get array of values from an Object.

Usage:

<template repeat="{{value in items | values}}">
 {{value}}
</template>

keyValue

Get array of keys and values from an Object.

Usage:

<template repeat="{{item in items | keyValue}}">
 {{item.key}} : {{item.value}}
</template>

date

Format a date using moment.js.

Usage:

{{item.date | date}}
{{item.date | date('LLL')}}

fromNow

Get relative time from now.

Usage:

{{item.date | fromNow}} <!-- 2 weeks ago. -->

calendar

Get relative 'calendar' time.

Usage:

{{item.date | fromNow}} <!-- 2 weeks ago. -->

TODO

Examples and tests.

License

MIT

Keywords

components

FAQs

Package last updated on 12 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts