title: Create Sitecore cshtml Rendering for Inserting JavaScript
body: <p>I need to create a cshtml rendering and Sitecore control that allows me to insert JavaScript from a Sitecore field. I can then attach this control to the layout to insert the JavaScript on the page.</p>
  
  <p>I tried inserting <code>&lt;script&gt;</code> into a control that uses a rich text editor, but Sitecore strips out <code>&lt;script&gt;</code> from the editor by default, which led me to this solution.</p>
  
  <p>I know the basics--there needs to be the cshtml rendering, a template (assuming one field only, a multiline text field), and a layout rendering with the path to the cshtml file, but not much more than that. </p>
  
  <p>The developers have used Glass Mapper, I don't know how that plays into the above, or how to re-instance this. This will be my first control. Here's a sample cshtml file if it helps:</p>
  
  <pre><code>@inherits Glass.Mapper.Sc.Web.Mvc.GlassView&lt;Company.Model.TDS.sitecore.templates.User_Defined.Company.Platform.Modules.Common.Sidebar_Text_Callout&gt;
  
      @if (Model != null)
      {
          &lt;div class="sidebar-text-callout"&gt;
              &lt;h3&gt;@Editable(Model, x =&gt; x.Sidebar_Callout_Title)&lt;/h3&gt;
              &lt;p&gt;@Editable(Model, x =&gt; x.Sidebar_Callout_Copy)&lt;/p&gt;
              @if (Model.Sidebar_Callout_Link != null)
              {
                  &lt;div class="all-caps-callout"&gt;
                      &lt;a class="link-with-icon" href="@Model.Sidebar_Callout_Link.Url" target="@Model.Sidebar_Callout_Link.Target"&gt;@Model.Sidebar_Callout_Link.Text &lt;span class="svg"&gt;@Html.Partial("~/Views/Icons/arrowRight.cshtml")&lt;/span&gt;&lt;/a&gt;
                  &lt;/div&gt;
              }
          &lt;/div&gt;
      }
  </code></pre>