PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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