groue / GRMustache

Flexible and production-ready Mustache templates for MacOS Cocoa and iOS
http://mustache.github.com/
MIT License
1.44k stars 190 forks source link

How can you pass in a literal value from a template into to a filter? #37

Closed sl1m3d closed 11 years ago

sl1m3d commented 11 years ago

trying to do something like this: {{date_format(date,"yyyy-MM-dd 'at' HH:mm")}}

or

{{#equals(name,"fred")}}this guys name is short for fredrick! {{/}}

I see a path for the second scenario but that involves adding a @{@"fred" : @"fred"} to the context which seems silly.

groue commented 11 years ago

Hi Rob.

There is, today, no way to write literals such as strings and numbers in the tag content.

I would consider a pull request with the greatest interest.

In the meantime, put your format in the data, as in https://gist.github.com/3803707.

groue commented 11 years ago

Obsoleted by #54

groue commented 11 years ago

The pull request #54 contains sample code that lets you render, for instance, the following template:

foo: {{ "foo" }}, FOO: {{ uppercase("foo") }}

as:

foo: foo, FOO: FOO
groue commented 11 years ago

@psybert Check the sample code at https://github.com/groue/GRMustache/pull/54#issuecomment-21967544 : literals have finally found their solution.

sl1m3d commented 11 years ago

Yea this looks awesome. Can't wait to try it out!