1

Long story short Client provides us with Smarty Templates on Front end. The .Net port of Smarty (Sharpy) is capable of converting all of those templates and use just like we use RAZOR templates. I am unable to figure out how to switch the templating engine to render the Sharpy files instead of RAZOR files so that the Views need not be converted to RAZOR and avoid a lot of code-rewrite that is happening right now.

What I've tried:

  1. I added “sharpy” as valid extension in Sitecore MVC configuration.
  2. I added Sharpy.dll and System.ComponentModel.Composition.dll as reference in the project – required as per the Sharpy documentation.
  3. I added view engine in application_start function of global.asax ( ViewEngines.Engines.Add(new SharpyViewEngine()) );
  4. I added view engine in initialization pipeline – to make sure it’s available

Error:

There is no Build Provider registered for the Extension '.sharpy'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

I am unable to find the exact cause. Googling did not help much as almost all of the users prefer RAZOR to be used. Also need to know what build provider will be applicable here.

UPDATE: Can I find a post/blog on exactly how it is done. Its okay even if it is some other templating engine! I may be able to get around even if that is available.

P.S.: I am new to both .Net/Visual Studio and Sitecore, so any help appreciated

4

1 回答 1

1
  1. 在 Project -> Pipeline -> Initialize -> Sharpy.cs 中创建新的 Sitecore 初始化管道,在 Process 函数中添加代码以添加视图引擎ViewEngines.Engines.Add(new SharpyViewEngine())

  2. 添加/修改您的项目配置以使用处理器标签添加新的管道代码

    <pipeline><initialize><processor patch:after="processor[@type='Sitecore.Pipeline.Loader.EnsureAnonymousUsers, Sitecore.Kernal']" type="Project.Pienter code herepelines.Initialize.Sharpy, Project.Domain /></initialize></pipeline>
    
  3. 将构建提供者标记添加到项目的 Web 配置文件中。

    <compilation><buildProviders><add extension=".sharpy" type='System.Web.Compilation.PageBuildProvider"/></buildProviders></compilation>
    
  4. 将 Shapry dll 文件添加到您的项目中作为参考。

  5. 在您的Sitecore.MVC.Config中添加sharpy作为有效扩展

    <sitecore><settings><setting name="MVC.ViewExtensions" value="|cshtml|sharpy|"/></settings></sitecore>
    
  6. 重建整个项目,发布然后检查。

  7. 现在您的系统开始执行 Sharpy 视图引擎,Sharpy 将开始执行 .Sharpy 文件。

于 2017-03-22T10:08:30.383 回答