Skip to content
drewwilson edited this page Sep 13, 2010 · 29 revisions

Formatters provide you with a way to change the default rendering of a template.
To illustrate the way these Format Helpers work, we will pretend we have the following data in our database:

name price url date
Golden Pickles 4022 pickles.html 2009-02-23:12:23

When you are rendering your template, use the following Format Helpers to change the template is rendered.

$.formatDate(format, value);

This will format a date, and place it into the element defined by the selector.


$(".myclass").formatDate("m D Y, H:i", "date");

$.formatNumber(number, options);

This will format a number, and place it into the element defined by the selector.


$(".myclass").formatNumber("price", {
     decimals: 0,
     decPoint: ".",
     thousandsSep: ","
});
Options Description
decimals Number of decimals to show. Set the value to 0 if you do not want to have any decimals.
decPoint Define the character for the decimal point.
thousandsSep Define the character to separate the number in multiples of thousands.

$.formatLink(text, href, options);

This will format the link (<a>) defined by the selector before it is displayed.


$("a.myclass").formatLink("Product Name: {name}", "mysite.com/{url}", {
     title: "I am a link.",
     className: "cname",
     Target: "_blank"
});
Options Description
title Set the Title attribute for the Anchor Tag. Accepts a string.
className Set the Class attribute for the Anchor Tag. You can pass multiple Class Names, separated by spaces. This will only Add Class Names to the Anchor tag, and not remove any existing Class Names.
target Set the Target attribute for the Anchor Tag. Accepts a string

$.submitsTo(controller, options);


$("form.myclass").submitsTo(controller, {

});