/modules/mod_base/filters/filter_after.erl

http://github.com/zotonic/zotonic · Erlang · 36 lines · 14 code · 6 blank · 16 comment · 0 complexity · 4a22ea36482433d93174cce3b824b445 MD5 · raw file

  1. %% @author Marc Worrell <marc@worrell.nl>
  2. %% @copyright 2010 Marc Worrell
  3. %% @doc 'after' filter, return the element after another element in a list
  4. %% Copyright 2010 Marc Worrell
  5. %%
  6. %% Licensed under the Apache License, Version 2.0 (the "License");
  7. %% you may not use this file except in compliance with the License.
  8. %% You may obtain a copy of the License at
  9. %%
  10. %% http://www.apache.org/licenses/LICENSE-2.0
  11. %%
  12. %% Unless required by applicable law or agreed to in writing, software
  13. %% distributed under the License is distributed on an "AS IS" BASIS,
  14. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. %% See the License for the specific language governing permissions and
  16. %% limitations under the License.
  17. -module(filter_after).
  18. -export(['after'/3]).
  19. 'after'(undefined, _, _Context) ->
  20. undefined;
  21. 'after'(_, undefined, _Context) ->
  22. undefined;
  23. 'after'(L, V, Context) ->
  24. next_of1(z_template_compiler_runtime:to_list(L, Context), V).
  25. next_of1([], _V) ->
  26. undefined;
  27. next_of1([V,N|_T], V) ->
  28. N;
  29. next_of1([_|T], V) ->
  30. next_of1(T, V).