Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html2haml does not handle metadata embedded in class attribute or child element #6

Open
norman opened this issue Jun 25, 2012 · 0 comments

Comments

@norman
Copy link
Contributor

norman commented Jun 25, 2012

Note: this was originally reported by @goneflyin as haml/haml#416.

The jQuery Metadata Plugin supports storage of meta in classes, random attributes, child elements and HTML5 data attributes. Two of these techniques work in haml, but storing the metadata in the class attribute, or in a child element, does not convert into proper haml. Because html2haml assumes all data within the class attribute is intended to be used as such.

Using the sample HTML from the plugin's web page, I've produced the following example.

> cat orig.html                                                                                                               
<html>
  <body>
    <ul>
      <li class="someclass {some: 'data'} anotherclass">...</li>
      <li data="{some:'random', json: 'data'}">...</li>
      <li>
        <script type="data">{some:"json",data:true}</script>...</li>
      <li data-some="'random'" data-json="'data'">...</li>
    </ul>
  </body>
</html>
> html2haml orig.html                                                                                                         
%html
  %body
    %ul
      %li.someclass.anotherclass{:class => "{some: 'data'}"} ...
      %li{:data => "{some:'random', json: 'data'}"} ...
      %li
        %script{:type => "data"}> {some:"json",data:true}
        \...
      %li{"data-json" => "'data'", "data-some" => "'random'"} ...
> html2haml orig.html | haml                                                                                                  
<html>
  <body>
    <ul>
      <li class="'data'} anotherclass someclass {some:">...</li>
      <li data="{some:'random', json: 'data'}">...</li>
      <li><script type='data'>{some:"json",data:true}</script>...
      </li>
      <li data-json="'data'" data-some="'random'">...</li>
    </ul>
  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant