Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Jig Razor Generator
Jig Razor Generator

Jig Razor Generator

J.Baltika

|
965 installs
| (0) | Free
Add to the custom tools => JigRazorGenerator
Download

This is a Custom Tool for Visual Studio that allows processing Razor files at design time instead of runtime, allowing them to be built into an assembly for simpler reuse and distribution. 
Installation instructions
It’s on the VS extension gallery, so install it from there. It’s called “JigRazorGenerator” (not to be confused with “Razor Single File Generator for MVC” or "Razor Generator"). They quite silmilar that all these extensions do, but the actual output varies. This extension tailored to work with HtmlWriter and ASP.NET controls. The main difference is that JigRazorGenerator allow specify, namespace, class name, method name and inherence 


@* GO TO => File Properties => Add to Custom Tool => JigRazorGenerator *@
@* ClassNamespace = Jig.Sitecore.Sites.LaunchSitecore.Views *@@* ClassName = PageLinkCalloutView *@@* ClassMethod = RenderPartialView *@
Optional:

  @* IsOverride = true *@

this will allow modify 

protected override void RenderView(HtmlTextWriter writer) {


Note that this tool only supports C#.

 

Add cs extension with references to System.Web.WebPages.Razor & System.Web.WebPages to run in any project or library:

namespace System.Web.UI{    using System.Web.WebPages;    using System.Web.WebPages.Instrumentation;     /// <summary>    /// Html Writer extension for Razor File Generator    /// </summary>    /// <remarks>This is Generic Razor code generation extension.</remarks>    public static class HtmlTextWriterExtensions    {        /// <summary>        /// Razor 2.0        /// Writes attribute in situations like &lt;img src="@Model"&gt;.        /// </summary>        /// <param name="writer">The writer.</param>        /// <param name="attribute">The attribute.</param>        /// <param name="prefix">The prefix.</param>        /// <param name="suffix">The suffix.</param>        /// <param name="values">The values.</param>        public static void WriteRazorAttribute(            this HtmlTextWriter writer,            // ReSharper disable UnusedParameter.Global            string attribute,            // ReSharper restore UnusedParameter.Global            PositionTagged<string> prefix,            PositionTagged<string> suffix,            params AttributeValue[] values)        {            // ReSharper disable ConditionIsAlwaysTrueOrFalse            if (writer != null)            {                // ReSharper restore ConditionIsAlwaysTrueOrFalse                writer.Write(prefix.Value);                 // ReSharper disable ConditionIsAlwaysTrueOrFalse                if (values != null)                {                    // ReSharper restore ConditionIsAlwaysTrueOrFalse                    foreach (var attributeValue in values)                    {                        writer.Write(attributeValue.Prefix.Value);                         var value = attributeValue.Value.Value;                        if (value != null)                        {                            writer.Write(value);                        }                    }                }                 writer.Write(suffix.Value);            }        }    }}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft