Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Framework / IViewEngine.cs
blobdc5877da5e2a4d307387a78dbdc1f8307f9bb78f
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.IO;
20 /// <summary>
21 /// Depicts the contract used by the engine
22 /// to process views, in an independent manner.
23 /// </summary>
24 public interface IViewEngine
26 /// <summary>
27 /// Gets a value indicating whether the view engine
28 /// support the generation of JS.
29 /// </summary>
30 /// <value>
31 /// <c>true</c> if JS generation is supported; otherwise, <c>false</c>.
32 /// </value>
33 bool SupportsJSGeneration { get; }
35 /// <summary>
36 /// Gets or sets a value indicating whether the view engine should set the
37 /// content type to xhtml.
38 /// </summary>
39 /// <value><c>true</c> if the content type should be set to xhtml; otherwise, <c>false</c>.</value>
40 bool XHtmlRendering { get; set; }
42 /// <summary>
43 /// Gets the view template file extension.
44 /// </summary>
45 /// <value>The view file extension.</value>
46 String ViewFileExtension { get; }
48 /// <summary>
49 /// Gets the JS generator view template file extension.
50 /// </summary>
51 /// <value>The JS generator file extension.</value>
52 String JSGeneratorFileExtension { get; }
54 /// <summary>
55 /// Evaluates whether the specified template exists.
56 /// </summary>
57 /// <returns><c>true</c> if it exists</returns>
58 bool HasTemplate(String templateName);
60 /// <summary>
61 /// Evaluates whether the specified template can be used to generate js.
62 /// </summary>
63 /// <returns><c>true</c> if it exists</returns>
64 bool IsTemplateForJSGeneration(String templateName);
66 /// <summary>
67 /// Processes the view - using the templateName
68 /// to obtain the correct template,
69 /// and using the context to output the result.
70 /// </summary>
71 void Process(IRailsEngineContext context, IController controller, String templateName);
73 ///<summary>
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!
78 /// </summary>
79 void Process(TextWriter output, IRailsEngineContext context, IController controller, String templateName);
81 /// <summary>
82 /// Implementors should return a generator instance if
83 /// the view engine supports JS generation.
84 /// </summary>
85 /// <param name="context">The request context.</param>
86 /// <returns>A JS generator instance</returns>
87 object CreateJSGenerator(IRailsEngineContext context);
89 /// <summary>
90 /// Processes the js generation view template - using the templateName
91 /// to obtain the correct template, and using the context to output the result.
92 /// </summary>
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);
98 /// <summary>
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.
102 /// </summary>
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);
109 /// <summary>
110 /// Should process the specified partial. The partial name must contains
111 /// the path relative to the views folder.
112 /// </summary>
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);
119 /// <summary>
120 /// Wraps the specified content in the layout using
121 /// the context to output the result.
122 /// </summary>
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);