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

logout icon disappeared in erb format #1582

Closed
wuzhonglin opened this Issue Feb 11, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@wuzhonglin

wuzhonglin commented Feb 11, 2014

When I use 0.12.0, and generate admin page for erb renderer, and then I found that the logout button icon disappeared.The html code generated is :

<li class=navbar-logout><form class="navbar-nav-form" method="post" action="/admin/sessions/destroy" protect_from_csrf="true" accept-charset="UTF-8"><input name="method" value="delete" type="hidden" /><input name="authenticitytoken" value="a883c8e92aff2275111d18c82256e670" type="hidden" /></form></li>

But the haml renderer generated as follow, and normally showed:

<li class='navbar-logout'><form class="navbar-nav-form" method="post" action="/admin/sessions/destroy" protect_from_csrf="true" accept-charset="UTF-8"><input name="method" value="delete" type="hidden" /><input name="authenticitytoken" value="d9b98e2f2d7de05fd81b014e2c5c3699" type="hidden" /><button type="submit" title="Exit the admin" class="navbar-nav-form-link"><i class="icon-off"></i> </button></form> </li>

@nesquena nesquena added this to the 0.12.1 milestone Feb 11, 2014

@wuzhonglin

This comment has been minimized.

Show comment
Hide comment
@wuzhonglin

wuzhonglin Feb 12, 2014

For above reason:
in padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb
the method

def engine_matches?(block) 

respected true or false, but the implemetion make it not only true or false,
many times it may return "local-variable" etc, and then make the the

capture_html(*args, &block) 

return wrong result.

Can fix it as below:

        ##
        # Returns true if the block is Erb.
        #
        def engine_matches?(block)
          if block.binding.eval('defined? __in_erb_template') != true
            return false
          else
            return true
          end
        end

wuzhonglin commented Feb 12, 2014

For above reason:
in padrino-helpers-0.12.0/lib/padrino-helpers/output_helpers/erb_handler.rb
the method

def engine_matches?(block) 

respected true or false, but the implemetion make it not only true or false,
many times it may return "local-variable" etc, and then make the the

capture_html(*args, &block) 

return wrong result.

Can fix it as below:

        ##
        # Returns true if the block is Erb.
        #
        def engine_matches?(block)
          if block.binding.eval('defined? __in_erb_template') != true
            return false
          else
            return true
          end
        end
@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Feb 12, 2014

Member

I can confirm that there's something wrong with erb admin layout generated by padrino-admin. Going to investigate.

Member

ujifgc commented Feb 12, 2014

I can confirm that there's something wrong with erb admin layout generated by padrino-admin. Going to investigate.

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Feb 12, 2014

Member

Closing in favor of #1585

Until it passes through you can patch your admin panel with this:

---<%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') { content_tag :button, tag_icon(:off), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } %>
+++<% button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') do %>
+++<%= content_tag :button, tag_icon(:off), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' %>
+++<% end %>
Member

ujifgc commented Feb 12, 2014

Closing in favor of #1585

Until it passes through you can patch your admin panel with this:

---<%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') { content_tag :button, tag_icon(:off), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } %>
+++<% button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') do %>
+++<%= content_tag :button, tag_icon(:off), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' %>
+++<% end %>

@ujifgc ujifgc closed this Feb 12, 2014

ujifgc added a commit that referenced this issue Feb 13, 2014

Merge pull request #1588 from minad/1582
ensure that captured blocks in erb and slim templates return nil, fixes #1582

claudiob added a commit to claudiob/middleman that referenced this issue Nov 8, 2014

Import patch to bugfix from Padrino Helpers
Padrino had an issue padrino/padrino-framework#1582
which was solved at padrino/padrino-framework@72769fe#diff-526024418d0d573e08d46ba3d55c02bcR36

This commit brings the same fix back into Middleman's method that
overrides Padrino's method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment