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

erb2slim doesn't handle ERB fragments within a tag definition properly #20

Open
MrJoy opened this issue Jun 27, 2014 · 4 comments
Open

Comments

@MrJoy
Copy link

MrJoy commented Jun 27, 2014

This:

<tr>
  <td class="firstcol <%= ' first_row_cell'.html_safe if params[:iphone] -%>">
    <%= f.label :login, "Email" %>
  </td>
  <td <%= 'class="first_row_cell"'.html_safe if params[:iphone] -%> >
    <%= f.text_field 'login', :value => base_login, :class => 'textfield', :placeholder => '[email protected]' %> 
  </td>
</tr>

Becomes:

tr
  |  <td class="firstcol 
  = ' first_row_cell'.html_safe if params[:iphone] -
  | "> 
  = f.label :login, "Email"
  |  <td 
  = 'class="first_row_cell"'.html_safe if params[:iphone] -
  |  > 
  = f.text_field 'login', :value => base_login, :class => 'textfield', :placeholder => '[email protected]'
@defaye
Copy link

defaye commented Jul 7, 2014

I'm assuming I've experienced the same issue:

erb code:

  <div id='category_<%= category.id %>' class='category'>

conversion expectation:

  .category id="category_#{category.id}" 

actual conversion error:

  #category_<ruby code="= category.id"></ruby>.category

@joaomilho
Copy link
Member

Yes, that's a problem. Will take a look into it ASAP.

@joaomilho
Copy link
Member

So I took a look and given the (hacky) way we do erb parsing on it it's going to be a lil tricky. But I'm still thinking about a proper solution.

@joaomilho
Copy link
Member

You're right about the expected output on ruby inside an attribute, but on ruby inside a tag this is the right output:

  <td <%= 'class="first_row_cell"'.html_safe if params[:iphone] -%> >
  td class=("first_row_cell"'.html_safe if params[:iphone])

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

3 participants