towerjscoffeekup

Overriding template logic in TowerJS Views


How do I override how templates are rendered in TowerJS? I know I can use Jade, but if I stuck with CoffeeKup, how could I, for instance have this code:

formFor @user, (form) ->
  form.fieldset "Profile", (fields) ->
    fields.field "firstName"
    fields.field "lastName"
    fields.field "email"
  form.fieldset "Address", (fields) ->
    fields.field "lat", as: hidden
    fields.field "lng", as: hidden
    fields.field "street"
    fields.field "city", as: "select", collection: ["CA"]

... generate this:

<form class='form' data-method='post' method='post' novalidate='true' role='form'>
  <fieldset class='fieldset' id='profile'>
    <legend class='legend'>
      <span>Profile</span>
    </legend>
    <li class='field-list'>
      <li class='field string optional validate'>
        <label class='label' for='active-record-user-first-name-input'>
          <span>First Name</span>

...instead of this:

<form class='form' data-method='post' method='post' novalidate='true' role='form'>
  <fieldset class='fieldset' id='profile'>
    <legend class='legend'>
      <span>Profile</span>
    </legend>
    <ol class='field-list'>
      <li class='field string optional validate'>
        <label class='label' for='active-record-user-first-name-input'>
          <span>First Name</span>

I guess I'm nitpicking over the <ol> versus <ul>, but I am just starting use Tower in evaluation to Railway and Derby. Is this a CoffeKup question or Mint question?


Solution

  • You can customize that tag by setting:

    Tower.View.fieldListTag = 'ul' # or whatever
    

    The configuration variables are here: