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
  • 99,844
  • 45
  • 235
  • 372

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
  • 731
  • 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
  • 310,957
  • 84
  • 592
  • 636
0

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

Community
  • 1
  • 1
powtac
  • 40,542
  • 28
  • 115
  • 170
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,752
  • 25
  • 32