title: Razor syntax to render section based on condition
body: <p>I got a view with Layout defined.  In the layout, there is a section: </p>
  
  <p><code>@RenderSection("JavaScript", required: false)</code></p>
  
  <p>In the view, based on a condition, I want to either render certain JavaScript to the section or not.</p>
  
  <pre><code>@if (condition)
  { 
      @section JavaScript
      {
          &lt;script type="text/javascript&gt;
             $(document).ready(function(){
               //bla...
             });
          &lt;/script&gt;
      }
  }
  </code></pre>
  
  <p>The above syntax is wrong.  What's the correct syntax?</p>
  
  <h2>Edit</h2>
  
  <p>Basically, I got a partial view which needs to be rendered based on a condition.  If the condition is true, then I need to render the partial view together with some JavaScript for the partial view, which I want to go to the "JavaScript" section.  How can I do that?</p>