On Wed, May 12, 2010 at 5:00 PM, Yang Zhang <
yangha...@gmail.com> wrote:
> How do users of mustache deal with things like escaping, quoting, and
> other things that are typically done with "filters" in most templating
> languages (e.g. {{somevar | escape}})? Better yet, any approaches to
> auto-escaping for well-known target languages like HTML (a feature in
> several frameworks e.g. Django)?
HTML escaping is done by default in Mustache. For filters, it's best
to do any sort of data manipulating in your view.
For example, if you want to format a date somehow:
class MyView < Mustache
def items
@list_of_items
end
def formatted_date
self[:date].in_the_format_i_want
end
end
MyView.template = "
{{# items}}
{{name}} was created at {{formatted_date}}
{{/ items}}
"