Nitro is a Node.js application for simple and complex frontend development with a tiny footprint.
It provides a proven but flexible structure to develop your frontend code, even in a large team.
Keep track of your code with a modularized frontend. This app and the suggested atomic design and BEM concepts could help.
Nitro is simple, fast and flexible. It works on OSX, Windows and Linux. Use this app for all your frontend work.
NitroNet is a full integration of Nitro frontends into ASP.NET. It is based on the project TerrificNet which uses Veil of Chris Sainty in order to parse handlebars templates. Handlebars.js is the primary template engine of Nitro. In summary, NitroNet is a completely new and simple view engine for ASP.NET MVC web applications. NitroNet is created by Fabian Geiger.
As a popular sub project, we have extend NitroNet to use this .Net view engine in the Web Content Management System Sitecore. You can find more informations about this project under NitroNetSitecore.
You need your own Nitro project as precondition of this installation manuel. Please follow the beautiful guide of Nitro: Link
Create a ASP.NET MVC solution on your local machine with Visual Studio and compile the solution.
Please choose between variant A with Unity/CastleWindsor or B with another IoC Framework.
There are several ways to install NitroNet into Sitecore. The easiest way is to use NitroNet together with Unity or CastleWindsor. Execute following line in your NuGet Package Manager to install NitroNet for Sitecore:
PM >
Install-Package NitroNet.UnityModules
Optionally, we recommend to install the Unity.Mvc which is a lightweight Unity bootstrapper for MVC applications.
or
PM >
Install-Package NitroNet.CastleWindsorModules
To activate NitroNet it's important to add/register the new view engine in your application. You can do this, with these lines of code (Gist:
<%@Application Language='C#' %>
<%@ Import Namespace="NitroNet" %>
<script RunAt="server">
public void Application_Start()
{
ViewEngines.Engines.Add(DependencyResolver.Current.GetService<NitroNetViewEngine>());
}
</Script>
In this NuGet package, you got all necessary code classes to configure and register NitroNet with Unity. To activate NitroNet, please add these lines to your application (Gist)
public static void RegisterTypes(IUnityContainer container)
{
var rootPath = HostingEnvironment.MapPath("~/");
var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString();
new DefaultUnityModule(basePath).Configure(container);
}
Also you got all necessary code classes to configure and register NitroNet with CastleWindsor. To activate NitroNet add these lines to your application (https://gist.github.com/daniiiol/0f5c8f3cc8725d329e27e4c7bb6bb16f)
public static void RegisterTypes(IWindsorContainer container)
{
var rootPath = HostingEnvironment.MapPath("~/");
var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString();
new DefaultCastleWindsorModule(basePath).Configure(container);
}
You don't like Unity and you design your application with an other IoC framework? No Problem. In this case, you can install NitroNet only with our base package:
PM >
Install-Package NitroNet
Please extend your Global.asax in the same way as in scenario (A)
Actually, we only made a Unity integration with NitroNet. But it's easy to use another IoC Framework. Please follow our Unity sample as a template for you (Gist):
using Microsoft.Practices.Unity;
using NitroNet;
using NitroNet.Mvc;
using NitroNet.ViewEngine;
using NitroNet.ViewEngine.Cache;
using NitroNet.ViewEngine.Config;
using NitroNet.ViewEngine.IO;
using NitroNet.ViewEngine.TemplateHandler;
using NitroNet.ViewEngine.ViewEngines;
using System.Web;
using Veil.Compiler;
using Veil.Helper;
namespace NitroNet.UnityModules
{
public class DefaultUnityModule : IUnityModule
{
private readonly string _basePath;
public DefaultUnityModule(string basePath)
{
this._basePath = basePath;
}
public void Configure(IUnityContainer container)
{
this.RegisterConfiguration(container);
this.RegisterApplication(container);
}
protected virtual void RegisterConfiguration(IUnityContainer container)
{
INitroNetConfig nitroNetConfig = ConfigurationLoader.LoadNitroConfiguration(this._basePath);
UnityContainerExtensions.RegisterInstance<INitroNetConfig>(container, nitroNetConfig);
UnityContainerExtensions.RegisterInstance<IFileSystem>(container, (IFileSystem) new FileSystem(this._basePath, nitroNetConfig));
}
protected virtual void RegisterApplication(IUnityContainer container)
{
UnityContainerExtensions.RegisterInstance<AsyncLocal<HttpContext>>(container, new AsyncLocal<HttpContext>(), (LifetimeManager) new ContainerControlledLifetimeManager());
UnityContainerExtensions.RegisterType<IHelperHandlerFactory, DefaultRenderingHelperHandlerFactory>(container, (LifetimeManager) new ContainerControlledLifetimeManager(), new InjectionMember[0]);
UnityContainerExtensions.RegisterType<IMemberLocator, MemberLocatorFromNamingRule>(container);
UnityContainerExtensions.RegisterType<INamingRule, NamingRule>(container);
UnityContainerExtensions.RegisterType<IModelTypeProvider, DefaultModelTypeProvider>(container);
UnityContainerExtensions.RegisterType<IViewEngine, VeilViewEngine>(container);
UnityContainerExtensions.RegisterType<ICacheProvider, MemoryCacheProvider>(container);
UnityContainerExtensions.RegisterType<IComponentRepository, DefaultComponentRepository>(container, (LifetimeManager) new ContainerControlledLifetimeManager(), new InjectionMember[0]);
UnityContainerExtensions.RegisterType<ITemplateRepository, NitroTemplateRepository>(container, (LifetimeManager) new ContainerControlledLifetimeManager(), new InjectionMember[0]);
UnityContainerExtensions.RegisterType<INitroTemplateHandlerFactory, MvcNitroTemplateHandlerFactory>(container, (LifetimeManager) new ContainerControlledLifetimeManager(), new InjectionMember[0]);
}
}
}
Oh sorry... there's no Step 3 to work with NitroNet :)
... comming soon.
Thanks to all the people who made and released these awesome resources for free!
Special thanks to Marco Schälle and Stefan Schälle who fight for a smart way to integrate Frontends into ASP.NET and create the predecessor TerrificNet of NitroNet itself. Marco and Stefan were our opinion leaders of this product.
Also special thanks to Mark Cassidy for all product commits and propagation of our idea to the whole world.