npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

expressions

1.1.4

@timoxley

npmHomeRepoSnykSocket
Downloads:65
$ npm install expressions
DailyWeeklyMonthlyYearly

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