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

content_tag with block doesn't work without Padrino::Rendering #1635

Closed
mnaoki opened this Issue Mar 28, 2014 · 11 comments

Comments

Projects
None yet
4 participants
@mnaoki

mnaoki commented Mar 28, 2014

I use padrino-helpers as a Sinatra plugin.
Here is a simple code.

require 'sinatra'
require 'padrino-helpers'

register Padrino::Helpers

get '/' do
  puts content_tag(:div, 'test') # => '<div>test</div>'
  puts content_tag(:div) do
    "test"
  end # => '<div></div>'
  src = <<-ERB
    <%= content_tag(:div, 'test') %><%# => '<div>test</div>' %>
    <% content_tag(:div) do %>
      test
    <% end %><%# => empty string or nil? %>
  ERB
  erb src
end

content_tag with block doesn't return a valid string as commented in above.
I found a similar issue #1430, but it seems to be already fixed.

[Environment]
Padrino-helper: 0.12.0
Sinatra: 1.4.4
Ruby: ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Mar 28, 2014

Member

Thanks for the report.
The first problem is caused by the priority.
You should change the code to puts content_tag(:div){ "test" }
The second problem seems a bug, but you can avoid the problem by using Padrino::Rendering.
like this:

require 'sinatra'
require 'padrino-helpers'
require 'padrino-core'

register Padrino::Helpers
register Padrino::Rendering

get '/' do
...
Member

namusyaka commented Mar 28, 2014

Thanks for the report.
The first problem is caused by the priority.
You should change the code to puts content_tag(:div){ "test" }
The second problem seems a bug, but you can avoid the problem by using Padrino::Rendering.
like this:

require 'sinatra'
require 'padrino-helpers'
require 'padrino-core'

register Padrino::Helpers
register Padrino::Rendering

get '/' do
...
@mnaoki

This comment has been minimized.

Show comment
Hide comment
@mnaoki

mnaoki Mar 28, 2014

Thank you for your quick reply.
The first is resolved with it, but the second is still not print the content.
I tried the latest HEAD of the master too, but the problem is not resolved.

If I define a variable '__in_erb_template = true' in the template, it can print a valid string.

mnaoki commented Mar 28, 2014

Thank you for your quick reply.
The first is resolved with it, but the second is still not print the content.
I tried the latest HEAD of the master too, but the problem is not resolved.

If I define a variable '__in_erb_template = true' in the template, it can print a valid string.

@ujifgc ujifgc added wontfix and removed wontfix labels Mar 28, 2014

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Mar 28, 2014

Member

If I define a variable '__in_erb_template = true' in the template, it can print a valid string.

And if you do that then another absurd thing fails to render: <%= content_tag(:div){ 'test3' } %>

What to do, what to do…

Member

ujifgc commented Mar 28, 2014

If I define a variable '__in_erb_template = true' in the template, it can print a valid string.

And if you do that then another absurd thing fails to render: <%= content_tag(:div){ 'test3' } %>

What to do, what to do…

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Mar 29, 2014

Member

Hmm, I'd suggest to fix the extension of erubis, and move Padrino::Rendering to padrino-support from padrino-core.
padrino-helpers should be able to use without padrino-core.

Member

namusyaka commented Mar 29, 2014

Hmm, I'd suggest to fix the extension of erubis, and move Padrino::Rendering to padrino-support from padrino-core.
padrino-helpers should be able to use without padrino-core.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Mar 29, 2014

Member

@mnaoki I've got a question.
Is your Gemfile including gem 'erubis'?
If not, erubis extension file will occur the LoadError, then doesn't extend the classes.

Member

namusyaka commented Mar 29, 2014

@mnaoki I've got a question.
Is your Gemfile including gem 'erubis'?
If not, erubis extension file will occur the LoadError, then doesn't extend the classes.

@mnaoki

This comment has been minimized.

Show comment
Hide comment
@mnaoki

mnaoki Mar 29, 2014

No there isn't.
I'm outsidenow. I will test it when I get home.

mnaoki commented Mar 29, 2014

No there isn't.
I'm outsidenow. I will test it when I get home.

@ujifgc ujifgc changed the title from content_tag with block doesn,t work well to content_tag with block doesn't work without Padrino::Rendering Mar 29, 2014

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Mar 29, 2014

Member

@padrino/core-members I'm thinking, is there a case where standalone use of padrino-core (without padrino-helpers) would require Padrino::Rendering?

It's clear that blocky helpers are quite entangled with the extensions of Padrino::Rendering. We might just move this module to padrino-helpers.

Member

ujifgc commented Mar 29, 2014

@padrino/core-members I'm thinking, is there a case where standalone use of padrino-core (without padrino-helpers) would require Padrino::Rendering?

It's clear that blocky helpers are quite entangled with the extensions of Padrino::Rendering. We might just move this module to padrino-helpers.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Mar 29, 2014

Member

It's good.
I also think so.

Member

namusyaka commented Mar 29, 2014

It's good.
I also think so.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 29, 2014

Member

Yeah that seems to make sense to me as well as a better place for the rendering code. I don't see any reason it couldn't be moved there.

Member

nesquena commented Mar 29, 2014

Yeah that seems to make sense to me as well as a better place for the rendering code. I don't see any reason it couldn't be moved there.

@mnaoki

This comment has been minimized.

Show comment
Hide comment
@mnaoki

mnaoki Mar 30, 2014

@namusyaka I have tested it.
If I install the gem 'erubis', erb src and render :erb, src work normally.

mnaoki commented Mar 30, 2014

@namusyaka I have tested it.
If I install the gem 'erubis', erb src and render :erb, src work normally.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Mar 30, 2014

Member

@mnaoki Thanks for confirming.
@padrino/core-members Should we support erb?
If padrino-helpers is without erubis, it will fail.

Member

namusyaka commented Mar 30, 2014

@mnaoki Thanks for confirming.
@padrino/core-members Should we support erb?
If padrino-helpers is without erubis, it will fail.

@ujifgc ujifgc closed this in #1638 Mar 31, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment