1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 using Directive
= NVelocity
.Runtime
.Directive
.Directive
;
16 using DirectiveType
= NVelocity
.Runtime
.Directive
.DirectiveType
;
17 using IInternalContextAdapter
= NVelocity
.Context
.IInternalContextAdapter
;
18 using INode
= NVelocity
.Runtime
.Parser
.Node
.INode
;
19 using IRuntimeServices
= NVelocity
.Runtime
.IRuntimeServices
;
21 namespace Castle
.MonoRail
.Framework
.Views
.NVelocity
.CustomDirectives
26 public class SubSectionDirective
: Directive
28 private readonly string name
;
29 private NVelocityViewContextAdapter contextAdapter
;
30 private INode savedNode
;
32 public SubSectionDirective(String name
)
38 /// Return the name of this directive
40 public override String Name
43 set { throw new NotImplementedException(); }
47 /// Get the directive type BLOCK/LINE
49 public override DirectiveType Type
51 get { return DirectiveType.BLOCK; }
54 public override bool AcceptParams
60 /// How this directive is to be initialized.
62 public override void Init(IRuntimeServices rs
, IInternalContextAdapter context
, INode node
)
64 base.Init(rs
, context
, node
);
70 /// How this directive is to be rendered
72 public override bool Render(IInternalContextAdapter context
, TextWriter writer
, INode node
)
76 throw new MonoRailException("context is null");
79 if (contextAdapter
== null)
81 throw new MonoRailException("contextAdapter is null");
84 if (contextAdapter
.ContextVars
== null)
86 throw new MonoRailException("contextAdapter.ContextVars is null");
89 // foreach(DictionaryEntry entry in contextAdapter.ContextVars)
91 // context.Put(entry.Key.ToString(), entry.Value);
94 for(int i
=0; i
< savedNode
.ChildrenCount
; i
++)
96 INode childNode
= savedNode
.GetChild(i
);
97 childNode
.Render(context
, writer
);
103 internal NVelocityViewContextAdapter ContextAdapter
105 set { contextAdapter = value; }