0

NHAML プロジェクト ページでこれを直接見つけることができなかったので、NHaml を使用するために ASP.NET MVC を実行する必要があるかどうか、または「通常の」ASP.NET Web ページでこれを使用できるかどうか疑問に思っていましたか?

また、Sass のリクエストをインターセプトし、ビルダーを手動で呼び出す必要があることを読みましたか?

4

2 に答える 2

1

ここでの回答と多少重複する質問: NHaml を汎用テンプレート エンジンとして使用できますか? (MVCの外部)

見積もり:

はい、ASP.Net MVC なしで使用できます。私は自分の Web サーバーに使用しています (ただし、Web サーバーで使用する必要があるという意味ではありません)。

ここで使用方法を確認してください: http://webserver.codeplex.com/SourceControl/changeset/view/50874#671672

要するに、次のようなことです。

TemplateEngine _templateEngine = new TemplateEngine();

// Add a type used in the template. Needed to that nhaml can

テンプレートをコンパイルするときに見つけます _templateEngine.Options.AddReferences(typeof (TypeInYourAssembly));

// base class for all templates
_templateEngine.Options.TemplateBaseType

= typeof (BaseClassForTemplates);

//class providing content to the engine, should implement

ITemplateContentProvider _templateEngine.Options.TemplateContentProvider = これ;

// compile the template, 
CompiledTemplate template = _templateEngine.Compile(new List<string> {layoutName, viewPath},
                                                                typeof (TemplateImplementation));

//create a instance
var instance = (NHamlView)template.CreateInstance();

// provide the view data used by the template
instance.ViewData = viewData;

// render it into a text writer
instance.Render(writer);
于 2010-12-22T17:23:58.520 に答える
0

いいえ、実装はありますが、ASP.NET MVC は必要ありません。必要に応じて、コンソール アプリケーションでも NHaml テンプレートを処理できます。

于 2010-11-24T08:49:23.350 に答える