donpark / html2jade

Converts HTML to Jade template. Not perfect but useful enough for non-daily conversions.
MIT License
1.18k stars 157 forks source link

Not generating nested elements #105

Closed scarrick68 closed 8 years ago

scarrick68 commented 8 years ago

It is generating the ids and classes of the nested elements indented and on new lines, but excluding the elements themselves. Here is a snippet of original HTML and the corresponding Jade that was generated:

<div ng-controller="playerCtrl">
    <div id="playerTop" class="player-top">
        <div class="paid-tv"  ng-if="user.type != 'free'">
            <div class="main-player position-div">
                <div id="tv-player"></div>
            </div>
        </div>
div(ng-controller='playerCtrl')
  #playerTop.player-top
    .paid-tv(ng-if="user.type != 'free'")
      .main-player.position-div
        #tv-player
    | 

I wasn't sure if this is a jade shorthand for nesting the same type of element. I didn't see it in their docs, but correct me if I'm wrong.

It compiles back to HTML with reconstituted divs. Is there a way to explicitly have the nested divs preserved when I do HTML to Jade?

donpark commented 8 years ago

That is how Jade works which is modeled after CSS selector syntax. I'm surprised Jade documentation doesn't say this explicitly.

donpark commented 8 years ago

re your 'excluding the elements themselves' comment, div elements are omitted if an ID or CSS style is defined. html2jade just prefers to omit but jade will also allows div.paid-tv.