0

Are there a javascript template engine which supports formatters?

That is, I can tell the template engine that it should be using a custom formatter (with a clean syntax).

Something like (borrowing jsrender syntax):

<td>{{:DateOfBirth, 'PrettyDate'}}</td>

Where 'PrettyDate' is mapped to a function which formats the date in a certain way.

jgauffin
  • 97,689
  • 42
  • 231
  • 359

4 Answers4

1

Mustache supports lambda's, you can get the same effect.

http://mustache.github.com/mustache.5.html

https://github.com/janl/mustache.js

Jason Palmer
  • 721
  • 4
  • 17
0

jinjs, the JavaScript version of Jinja2 supports filters which do pretty much what you want. In your case the syntax would be {{ DAteOfBirth | PrettyDate }}

ThiefMaster
  • 298,938
  • 77
  • 579
  • 623
0

Check out Underscore.js, it supports formatters, see: How to use underscore.js as a template engine?

Community
  • 1
  • 1
powtac
  • 39,317
  • 26
  • 112
  • 166
0

Distal templates supports formatters, see http://code.google.com/p/distal/wiki/Syntax#Formatting_data_into_numerical_form

It looks like:

<input data-qattr="value total_cost ,.">

where the ",." implies numbers with thousands separator (1,000,000.00)

Kernel James
  • 3,226
  • 20
  • 22