2010-11-24 10 views
0

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

また、Sassのリクエストを傍受し、手動でビルダーに電話する必要があるとお読みになりましたか?

答えて

0

いいえ、実装はありますが、ASP.NET MVCは必要ありません。 NHamlテンプレートは、コンソールアプリケーションでも処理できます。多少ここでの答えと重複

+0

私は今実行しているが、NHamlをインストールするには、ガイドを以下のとき、私はどこでもNhamlためControllerBuilderを見つけることができないようMVC 2持っているので、私は、現在入手方法について考え出しますよNhamlはASp.NET MVC 2 –

1

質問:Can NHaml be used as a general purpose template engine? (outside of 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); 
+0

+1でリンクと情報の使用方法を有効にしました。 :) –

関連する問題