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 namespace Castle
.MonoRail
.Framework
18 using System
.Collections
.Generic
;
22 /// Depicts the contract used by the engine
23 /// to process views, in an independent manner.
25 public interface IViewEngine
28 /// Gets a value indicating whether the view engine
29 /// support the generation of JS.
32 /// <c>true</c> if JS generation is supported; otherwise, <c>false</c>.
34 bool SupportsJSGeneration { get; }
37 /// Evaluates whether the specified template can be used to generate js.
39 /// <returns><c>true</c> if it exists</returns>
40 bool IsTemplateForJSGeneration(String templateName
);
43 /// Gets the JS generator view template file extension.
45 /// <value>The JS generator file extension.</value>
46 string JSGeneratorFileExtension { get; }
49 /// Implementors should return a generator instance if
50 /// the view engine supports JS generation.
52 /// <param name="generatorInfo">The generator info.</param>
53 /// <param name="context">The request context.</param>
54 /// <param name="controller">The controller.</param>
55 /// <param name="controllerContext">The controller context.</param>
56 /// <returns>A JS generator instance</returns>
57 object CreateJSGenerator(JSCodeGeneratorInfo generatorInfo
, IEngineContext context
, IController controller
, IControllerContext controllerContext
);
60 /// Processes the js generation view template - using the templateName
61 /// to obtain the correct template, and using the specified <see cref="TextWriter"/>
62 /// to output the result.
64 /// <param name="templateName">Name of the template.</param>
65 /// <param name="output">The output.</param>
66 /// <param name="generatorInfo">The generator info.</param>
67 /// <param name="context">The request context.</param>
68 /// <param name="controller">The controller.</param>
69 /// <param name="controllerContext">The controller context.</param>
70 void GenerateJS(string templateName
, TextWriter output
, JSCodeGeneratorInfo generatorInfo
,
71 IEngineContext context
, IController controller
, IControllerContext controllerContext
);
74 /// Gets or sets a value indicating whether the view engine should set the
75 /// content type to xhtml.
77 /// <value><c>true</c> if the content type should be set to xhtml; otherwise, <c>false</c>.</value>
78 bool XHtmlRendering { get; set; }
81 /// Gets the view template file extension.
83 /// <value>The view file extension.</value>
84 string ViewFileExtension { get; }
87 /// Evaluates whether the specified template exists.
89 /// <returns><c>true</c> if it exists</returns>
90 bool HasTemplate(string templateName
);
93 /// Processes the view - using the templateName
94 /// to obtain the correct template
95 /// and writes the results to the <see cref="TextWriter"/>.
96 /// No layout is applied!
98 void Process(string templateName
, TextWriter output
, IEngineContext context
, IController controller
,
99 IControllerContext controllerContext
);
102 /// Processes the view - using the templateName
103 /// to obtain the correct template
104 /// and writes the results to the <see cref="TextWriter"/>.
105 /// No layout is applied!
107 void Process(string templateName
, string layoutName
, TextWriter output
, IDictionary
<string,object> parameters
);
110 /// Wraps the specified content in the layout using
111 /// the context to output the result.
113 /// <param name="context">The request context.</param>
114 /// <param name="controller">The controller.</param>
115 /// <param name="controllerContext">The controller context.</param>
116 /// <param name="contents">Static content to output within the layout</param>
117 void RenderStaticWithinLayout(string contents
, IEngineContext context
, IController controller
,
118 IControllerContext controllerContext
);
121 /// Should process the specified partial. The partial name must contains
122 /// the path relative to the views folder.
124 /// <param name="partialName">The partial name.</param>
125 /// <param name="output">The output.</param>
126 /// <param name="context">The request context.</param>
127 /// <param name="controller">The controller.</param>
128 /// <param name="controllerContext">The controller context.</param>
129 void ProcessPartial(string partialName
, TextWriter output
, IEngineContext context
, IController controller
,
130 IControllerContext controllerContext
);
132 // Holding it a little more as it would be a breaking change (meaning all partials view would break)
135 // /// Should process the specified partial. The partial name must contains
136 // /// the path relative to the views folder.
138 // /// <param name="partialName">The partial name.</param>
139 // /// <param name="output">The output.</param>
140 // /// <param name="context">The request context.</param>
141 // /// <param name="parameters">The parameters.</param>
142 // void ProcessPartial(String partialName, TextWriter output, IEngineContext context, IDictionary<string, object> parameters);