expressions

1.1.4 • Public • Published

expressions

Grab bag of template-binding expressions.

For use with new template-binding standards.

API

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

Package Sidebar

Install

npm i expressions

Weekly Downloads

1

Version

1.1.4

License

ISC

Last publish

Collaborators

  • timoxley