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

Formatters are 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
Golden Pickles 4022 pickles.html

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

$.formatDate(format, value);

This will append a date string to the given selector.


var datestamp = "2009-02-21 12:23";
$(".myclass").formatDate("m D Y, H:i", datestamp);

$.formatNumber(number, options);

This will append a numerical string to the given selector.


$(".myclass").formatNumber("price", {
});

$.formatLink(text, href, options);

This will append a link (<a>) to the given selector.


$("a.myclass").formatLink("Item: {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);

Clone this wiki locally