Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
link_to with block in slim doesn't seem to work #777
I am using slim as my template syntax and using a block with the
My test is like this:
== link_to("/") do span Hello
It doesn't print anything.
I digged into the code and traced it back to
def concat_to_template(text="") self.output_buffer << text if is_type? && text nil end
It doesn't come from the condition, I commented it and it didn't change anything.
For reference this all stems from: https://github.com/padrino/padrino-framework/blob/master/padrino-helpers/test/test_output_helpers.rb#L104 it's been a problem for a while as far as I understand.
I was bitten by this awhile ago. I have a few other changes, but I think this was all thats needed:
module Padrino module Helpers module OutputHelpers class SlimHandler < AbstractHandler def capture_from_template(*args, &block) buffer = '' old_buffer, @_out_buf = @_out_buf, buffer yield(*args) buffer ensure self.output_buffer = old_buffer end end end end end
added a commit
Apr 27, 2012
After investigate on it I can confirm problem with @WaYdotNET and Im unable to reproduce problem @simonc and @chevalun . Maybe latest slim 1.2.1 has fixed it? Can you guys update all your gems and retest it?
Which pass on all rubies.
Since we have some
== link_to '/' do span Hello World
<a href="/"><span>Hello World</span></a>
added a commit
Jun 11, 2012
Not sure if you figured this out by now, but I was trying to do something like:
li = link_to channel.name, channel_path(channel) do figure img src="//placekitten.com/g/400/200" h3 = channel.name p = channel.description
This didn't work. This is because I'm trying to set the content of the link with the first argument of
Once you remove that first argument:
Not sure if it helps but I recently switched to
Would render the whole page template again instead of just the link and found the reason to be streaming. I'm using
With streaming enabled it seems slim renders the block first (I got the content of the link outside, before it) and then renders the link with the whole template inside. So you may want to have a look at this in stream mode ;)