merged branch jonathaningram/patch-1 (PR #549)
merged branch jonathaningram/patch-1 (PR #549)

Commits
-------

989bb22 Removed trailing white spaces
f880bab Help the developer when they specify an invalid filter by providing some alternatives

Discussion
----------

Help the developer when they specify an invalid filter by providing some...

... alternatives.

Bug fix: no
Feature addition: yes
Backwards compatibility break: no

Uses a simple `strpos` search (no fancy diff to determine what the filter could be). There is no impact to runtime performance because this is all happening during template compilation.

Examples:

```jinja
{{ my_entity|json }}
```

Shows exception:

`The filter "json" does not exist. Did you mean "json_encode"?`

```jinja
{{ my_date|dat }}
```

Shows:

`The filter "dat" does not exist. Did you mean "date"?`

```jinja
{{ my_var|f }}
```

Shows:

`The filter "f" does not exist. Did you mean "format", "default", "_default", "format_args", "format_args_as_text", "file_excerpt", "format_file", "format_file_from_text", "file_link"?`

Also good for custom filters created in your own domain `st_`:

```jinja
{{ my_var|st_ }}
```

Shows:

`The filter "st_" does not exist. Did you mean "st_friendly_date", "st_site_test_url"?`

---------------------------------------------------------------------------

by stof at 2011/12/04 16:34:27 -0800

I like the idea to provide help to the developer in case of error. You should probably do the same for functions

---------------------------------------------------------------------------

by Tobion at 2011/12/05 05:56:29 -0800

+1 for a combination of string starts with (suggesting domain specific filters, e.g. st_*) and levenshtein for typos

---------------------------------------------------------------------------

by chucktrukk at 2011/12/05 08:13:10 -0800

+1. This would be really helpful.

dkarvounaris/Twig,nicolas-grekas/Twig,phansys/Twig,peterkokot/Twig,markstory/Twig,bocharsky-bw/Twig,jamessingizi/Twig,Rvanlaak/Twig,hhamon/Twig,twigphp/Twig,fsw/Twig,derickr/Twig,andrerom/Twig,znerol/Twig,iKwinto/Twig,hason/Twig,twigphp/Twig,bocharsky-bw/Twig,huang53798584/Twig,znerol/Twig,apishka/templater,gencer/Twig,robregonm/Twig,craue/Twig,loi-chuanoi/Twig,bocharsky-bw/Twig,sstok/Twig,framewr/Twig,framewr/Twig,moltin/Twig,gencer/Twig,andrerom/Twig,markstory/Twig,sstok/Twig,derickr/Twig,huang53798584/Twig,nicolas-grekas/Twig,moltin/Twig,Tobion/Twig,robregonm/Twig,hason/Twig,iKwinto/Twig,hason/Twig,twigphp/Twig,dkarvounaris/Twig,apishka/templater,maartendekeizer/Twig,fsw/Twig,huang53798584/Twig,znerol/Twig,craue/Twig,Tobion/Twig,robregonm/Twig,jamessingizi/Twig,jamessingizi/Twig,phansys/Twig,moufmouf/Twig,moltin/Twig,fsw/Twig,Tobion/Twig,gamernetwork/Twig,derickr/Twig,nicolas-grekas/Twig,iKwinto/Twig,moufmouf/Twig,gamernetwork/Twig,moufmouf/Twig,Rvanlaak/Twig,hhamon/Twig,dkarvounaris/Twig,hhamon/Twig,peterkokot/Twig,framewr/Twig,gamernetwork/Twig,maartendekeizer/Twig,nicolas-grekas/Twig,Rvanlaak/Twig,nicolas-grekas/Twig