Added clauses to truncate null-values and integers correctly. #29

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

gwitmond commented Jun 5, 2012

You get these with the postgres-adapter from boss_db.

Error messages are:
{function_clause,
[{erlydtl_filters,truncatewords,
[1800,8,[]],
[{file,"src/erlydtl_filters.erl"},{line,994}]},
...

and
function_clause,
[{erlydtl_filters,truncatewords,
[null,8,[]],
[{file,"src/erlydtl_filters.erl"},{line,994}]},
...

@gwitmond gwitmond Added clauses to truncate null-values and integers correctly.
You get these with the postgres-adapter from boss_db.

Error messages are:
{function_clause,
    [{erlydtl_filters,truncatewords,
         [1800,8,[]],
         [{file,"src/erlydtl_filters.erl"},{line,994}]},
    ...

and
function_clause,
    [{erlydtl_filters,truncatewords,
         [null,8,[]],
         [{file,"src/erlydtl_filters.erl"},{line,994}]},
    ...
bb6c24e
Contributor

evanmiller commented Jun 5, 2012

Looks OK but this should be more general, i.e. work with all atoms not just 'null'.

@gwitmond gwitmond Added filter date_unix_epoch that displays unix time in seconds since…
… 1-1-1970.

Added clauses to display 'undefined' for date and floatformat when input is undefined. This prevents an rendering error.
313edd5
Contributor

evanmiller commented Jan 16, 2013

Is date_unix_epoch standard in Django?

Owner

kaos commented Nov 28, 2013

I don't find date_unix_epoch among the built-in filters of django.

However, I like the changes that avoids crash on invalid input. But as Evan was into, I'd prefer them to be more generic. How about a catch all clause like:
filter(Invalid) -> io_lib:format("~p", [Invalid]).

Either that, or, have the runtime catch errors when applying filters and log the error, and return the empty string to the rendered result (look at the logs for errors, avoid leaking errors to potential end user).

kaos was assigned Nov 29, 2013

kaos closed this in c2001a9 Nov 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment