1 // Copyright 2004-2007 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
21 /// Depicts the contract used by the engine
22 /// to process views, in an independent manner.
24 public interface IViewEngine
27 /// Gets a value indicating whether the view engine
28 /// support the generation of JS.
31 /// <c>true</c> if JS generation is supported; otherwise, <c>false</c>.
33 bool SupportsJSGeneration { get; }
36 /// Gets or sets a value indicating whether the view engine should set the
37 /// content type to xhtml.
39 /// <value><c>true</c> if the content type should be set to xhtml; otherwise, <c>false</c>.</value>
40 bool XHtmlRendering { get; set; }
43 /// Gets the view template file extension.
45 /// <value>The view file extension.</value>
46 String ViewFileExtension { get; }
49 /// Gets the JS generator view template file extension.
51 /// <value>The JS generator file extension.</value>
52 String JSGeneratorFileExtension { get; }
55 /// Evaluates whether the specified template exists.
57 /// <returns><c>true</c> if it exists</returns>
58 bool HasTemplate(String templateName
);
61 /// Evaluates whether the specified template can be used to generate js.
63 /// <returns><c>true</c> if it exists</returns>
64 bool IsTemplateForJSGeneration(String templateName
);
67 /// Processes the view - using the templateName
68 /// to obtain the correct template,
69 /// and using the context to output the result.
71 void Process(IRailsEngineContext context
, IController controller
, String templateName
);
74 /// Processes the view - using the templateName
75 /// to obtain the correct template
76 /// and writes the results to the <see cref="TextWriter"/>.
77 /// No layout is applied!
79 void Process(TextWriter output
, IRailsEngineContext context
, IController controller
, String templateName
);
82 /// Implementors should return a generator instance if
83 /// the view engine supports JS generation.
85 /// <param name="context">The request context.</param>
86 /// <returns>A JS generator instance</returns>
87 object CreateJSGenerator(IRailsEngineContext context
);
90 /// Processes the js generation view template - using the templateName
91 /// to obtain the correct template, and using the context to output the result.
93 /// <param name="context">The request context.</param>
94 /// <param name="controller">The controller.</param>
95 /// <param name="templateName">Name of the template.</param>
96 void GenerateJS(IRailsEngineContext context
, IController controller
, String templateName
);
99 /// Processes the js generation view template - using the templateName
100 /// to obtain the correct template, and using the specified <see cref="TextWriter"/>
101 /// to output the result.
103 /// <param name="output">The output.</param>
104 /// <param name="context">The request context.</param>
105 /// <param name="controller">The controller.</param>
106 /// <param name="templateName">Name of the template.</param>
107 void GenerateJS(TextWriter output
, IRailsEngineContext context
, IController controller
, String templateName
);
110 /// Should process the specified partial. The partial name must contains
111 /// the path relative to the views folder.
113 /// <param name="output">The output.</param>
114 /// <param name="context">The request context.</param>
115 /// <param name="controller">The controller.</param>
116 /// <param name="partialName">The partial name.</param>
117 void ProcessPartial(TextWriter output
, IRailsEngineContext context
, IController controller
, String partialName
);
120 /// Wraps the specified content in the layout using
121 /// the context to output the result.
123 /// <param name="context">The request context.</param>
124 /// <param name="controller">The controller.</param>
125 /// <param name="contents">Content to output</param>
126 void ProcessContents(IRailsEngineContext context
, IController controller
, String contents
);