title: A way to display enum property as a string using handlebars
body: <p>everyone. Could you help me, or at least show a way? In my Asp.Net MVC project I have list of objects (cars). Each of them has enum type property (car state). I'm passing list to my view and using handlebars.js template in my view to get a list of my cars and display each car`s state. Template displays all the data i need, but unfortunately it displays enum property data as numeric values. Currently i'm trying to find a way to force template to display it as some sort of string description. Is there a way to do this? (Recently i've used regular @foreach and custom helper, so values where displayed using Resources, but now i need to use handlebars template and have no idea how to make something similar).</p>
  
  <p><strong>Handlebars template code:</strong></p>
  
  <pre><code>@model IEnumerable&lt;Model.DTO.CarDTO&gt;
  &lt;script id="carListRow" type="text/x-handlebars-template"&gt;
  {{#each cars}}
  &lt;tr&gt;
      &lt;td&gt;
          {{CarName}}
      &lt;/td&gt;
      &lt;td&gt;
          {{CarNickName}}
      &lt;/td&gt;
      &lt;td&gt;
          {{CarNumber}}
      &lt;/td&gt;
      &lt;td&gt;
          {{CarState}}
      &lt;/td&gt;
      &lt;td&gt;
          &lt;a class="btn btn-danger" href="#" data-cars-id="{{Id}}" data-cars-name="{{CarName}}" role="button" onclick="carController.deleteCar(this)"&gt;@Resources.Resource.deleteString&lt;/a&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  {{/each}}
  </code></pre>
  
  <p></p>
  
  <p><strong>Enum</strong></p>
  
  <pre><code>public enum CarStateEnum
  {
      Working = 1,
      Repairing = 2
  }
  </code></pre>
  
  <p><strong>Car model:</strong></p>
  
  <pre><code>public class Car
  {
      [Key]
      public int Id { get; set; }
      [Required]
      [StringLength(50, MinimumLength = 2)]
      public string CarName { get; set; }
      [Required]
      [StringLength(12, MinimumLength = 3)]
      public string CarNumber { get; set; }
      [Required]
      [Range(2,20)]
      public int CarOccupation { get; set; }
      [Required]
      public CarClassEnum CarClass { get; set; }
      [Required]
      public CarPetrolEnum CarPetrolType { get; set; }
      [Required]
      [Range(1, 100)]
      public int CarPetrolConsumption { get; set; }
      [Required]
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
      public DateTime CarManufactureDate { get; set; }
      [Required]
      public CarStateEnum CarState { get; set; }
      [Required]
      [StringLength(16, MinimumLength = 2)]
      public string CarNickName { get; set; }
  
      [ForeignKey("UserId")]
      public virtual User User { get; set; }
      public int UserId { get; set; }
  }
  </code></pre>
  
  <p><strong>And that how Car State is displayed:</strong>
  <a href="http://i.stack.imgur.com/n1jJU.png" rel="nofollow">Car State is numeric</a></p>
  
  <p>P.S.: Please excuse me for my grammar and other mistakes.</p>