add support for F#
[ohcount] / test / expected_dir / fs1.fs
1 fsharp  comment (***************************************************************************
2 fsharp  comment  * 
3 fsharp  comment  *  The Parser is free software: you can redistribute it and/or modify
4 fsharp  comment  *  it under the terms of the GNU Lesser General Public License as published by
5 fsharp  comment  *  the Free Software Foundation, either version 3 of the License, or
6 fsharp  comment  *  (at your option) any later version.
7 fsharp  comment  *  
8 fsharp  comment  ***************************************************************************)
9 fsharp  blank   
10 fsharp  code    namespace Tags
11 fsharp  blank   
12 fsharp  code    open System
13 fsharp  code    open System.Reflection;
14 fsharp  code    open System.Runtime.CompilerServices;
15 fsharp  code    open System.Runtime.InteropServices;
16 fsharp  blank   
17 fsharp  code    module internal Filter =
18 fsharp  blank   
19 fsharp  code        let FILTER_VARIABLE_NAME = "$filter"
20 fsharp  blank   
21 fsharp  code        type FilterNode(provider, token, filter: FilterExpression, node_list) =
22 fsharp  code            inherit TagNode(provider, token)
23 fsharp  blank   
24 fsharp  code            override this.walk manager walker = 
25 fsharp  code                let reader = 
26 fsharp  code                    new NDjango.ASTWalker.Reader (manager, {walker with parent=None; nodes=node_list; context=walker.context}) 
27 fsharp  code                match filter.ResolveForOutput manager
28 fsharp  code                         {walker with context=walker.context.add(FILTER_VARIABLE_NAME, (reader.ReadToEnd():>obj))}
29 fsharp  code                    with
30 fsharp  code                | Some w -> w
31 fsharp  code                | None -> walker
32 fsharp  blank   
33 fsharp  comment     /// Filters the contents of the block through variable filters.
34 fsharp  comment     /// 
35 fsharp  comment     /// Filters can also be piped through each other, and they can have
36 fsharp  comment     /// arguments -- just like in variable syntax.
37 fsharp  comment     /// 
38 fsharp  comment     /// Sample usage::
39 fsharp  comment     /// 
40 fsharp  comment     ///     {% filter force_escape|lower %}
41 fsharp  comment     ///         This text will be HTML-escaped, and will appear in lowercase.
42 fsharp  comment     ///     {% endfilter %}
43 fsharp  code        type FilterTag() =
44 fsharp  code            interface ITag with
45 fsharp  code                member this.Perform token provider tokens =
46 fsharp  code                    match token.Args with
47 fsharp  code                    | filter::[] ->
48 fsharp  code                        let filter_expr = new FilterExpression(provider, Block token, FILTER_VARIABLE_NAME + "|" + filter)
49 fsharp  code                        let node_list, remaining = (provider :?> IParser).Parse (Some token) tokens ["endfilter"]
50 fsharp  code                        (new FilterNode(provider, token, filter_expr, node_list) :> INodeImpl), remaining
51 fsharp  code                    | _ -> raise (SyntaxError ("'filter' tag requires one argument"))