handlebars-lang / handlebars.js

Minimal templating on steroids.
http://handlebarsjs.com
MIT License
18.01k stars 2.04k forks source link

Provide filters like Liquid? #159

Closed nimbupani closed 12 years ago

nimbupani commented 12 years ago

I have been using Liquid with Jekyll and have found it very trivial to do standard filters for some of the data.

I have also been using handlebars quite a bit for my node projects, but find that I need to write helpers all the time for any tiny manipulation or having more logic than an if statement.

I wonder if something like this would be useful in Handlebars? I don't think all the functionality of liquid is useful but chainable filters sound like something that would make me write less helper functions.

troyk commented 12 years ago

This is my 2nd favorite feature of dust http://akdubya.github.com/dustjs/ The 1st being template inheritance, I'm not sure how much handlebars wants to diverge from mustache, but filters and inheritance are awesome. Nothing has happened on dust since June and there are some good pull requests just sitting there. It seems handlebars has more momentum and activity, it would be nice to see these features adopted.

wagenet commented 12 years ago

I don't think this is a feature we're likely to add to Handlebars. If you'd like to chain multiple filters, I'd suggest implementing a filter helper that takes a property and array of filter names.

nijikokun commented 12 years ago

I made a few of these if it helps, I only needed a few but you can easily extend it.

https://gist.github.com/3861219

icholy commented 11 years ago

@wagenet what's the reasoning behind not wanting to add filters? I instantly fell in love with it when trying angular.

wagenet commented 11 years ago

@icholy Handlebars attempts to keep things relatively simple. Adding filters would significantly increase complexity. You can register your own custom helpers instead.

kevinSuttle commented 10 years ago

So, does HB work like Middleman's partial includes (not necessarily the same goal as templating)?

http://middlemanapp.com/basics/templates/#toc_6

kevinSuttle commented 10 years ago

Answered my own question. http://blog.teamtreehouse.com/handlebars-js-part-2-partials-and-helpers

kevinSuttle commented 10 years ago

Actually, that's not necessarily what I'm looking for. Something more like includes, http://jlongster.github.io/nunjucks/templating.html#include