title: Is there a way to hide html inside curly braces in an ASP.NET MVC Razor html helper?
body: <p>This is the closest thing I could find to this specific answer, but doesn't quite answer it for me. <a href="https://stackoverflow.com/questions/8292497/how-can-i-create-a-html-helper-like-html-beginform">How can I create a Html Helper like Html.BeginForm</a></p>
  
  <p>I have a current html.helper that hides (or shows) content based on the current server time. It's not really a problem, but an improvement I'd love to see here. So the HTML helper works like this:</p>
  
  <p>Html.DurationHtml works like this:</p>
  
  <pre><code>public static IHtmlString DurationHtml(this HtmlHelper html, string StartDateTime, string EndDateTime)
      {
          if (CentralLibrary.WithinDatespan(StartDateTime, EndDateTime))
          {
              var writer = html.ViewContext.Writer;
              return html.Raw(htmlContent);
          }
          else
          {
              return null;
          }
      }
  </code></pre>
  
  <p>CentralLibrary.WithinDatespan(start,end) is just a method that compares the current time (or a provided simulated time) with the date/times specified and returns true or false.</p>
  
  <p>I implement it like so:</p>
  
  <pre><code>@Html.DurationHtml("&lt;a href=\"link\"&gt;Content&lt;/a&gt;", "12/12/2015 12:00:01pm","12/12/2017 12:00:01pm") 
  </code></pre>
  
  <p>This works and does exactly what I want it to do, very well. My hope for an improvement here is to take the content out of the double quotes so that I don't have to escape the double quotes. The caveat here is that I cannot have the content sent to the browser at all. I know I could wrap a container with display set to none, but the content cannot be sent at all as some of the info may not be for public eyes until certain times. Is there a way I can make the html helper work like this and keep the content from being sent to the browser?</p>
  
  <pre><code>@using(Html.DurationHtml("12/12/2015 12:00:01pm","12/12/2017 12:00:01pm")){
  
       &lt;a href="link"&gt;Content&lt;/a&gt;
  
  }
  </code></pre>