Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
View Helpers in Mixed Erb/Haml environment
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
railsjedi  
View profile  
 More options Nov 20 2008, 1:40 am
From: railsjedi <jcnet...@gmail.com>
Date: Wed, 19 Nov 2008 22:40:11 -0800 (PST)
Local: Thurs, Nov 20 2008 1:40 am
Subject: View Helpers in Mixed Erb/Haml environment
Hi. I'm trying to write some view helpers that take blocks. Running
into the issue that some views are HAML and some are ERB. So erb seems
to break haml_tag, and haml seems to break content_tag. Also concat vs
haml_concat, and capture vs capture_haml. All very confusing. Seems
like helpers should be halpers, and work in all contexts no matter the
view layer.

Is there an easy way to convert from one to the other? Maybe by just
wrapping it in a capture block or something?

Thanks


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
railsjedi  
View profile  
 More options Nov 20 2008, 2:18 am
From: railsjedi <jcnet...@gmail.com>
Date: Wed, 19 Nov 2008 23:18:04 -0800 (PST)
Local: Thurs, Nov 20 2008 2:18 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
Or does anyone know of a similar implementation of haml_tag for erb?

On Nov 19, 10:40 pm, railsjedi <jcnet...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Weizenbaum  
View profile  
 More options Nov 20 2008, 2:19 am
From: Nathan Weizenbaum <nex...@gmail.com>
Date: Wed, 19 Nov 2008 23:19:28 -0800
Local: Thurs, Nov 20 2008 2:19 am
Subject: Re: [haml] View Helpers in Mixed Erb/Haml environment
All the ERB helpers should work with Haml - if they don't, that's a bug.
The Haml helpers do require Haml, so you should avoid using them in a
mixed environment. The reason things like haml_concat and capture_haml
exist is to provide something for non-Rails environments.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
railsjedi  
View profile  
 More options Nov 23 2008, 12:00 am
From: railsjedi <jcnet...@gmail.com>
Date: Sat, 22 Nov 2008 21:00:33 -0800 (PST)
Local: Sun, Nov 23 2008 12:00 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
Ok, I tracked all my frustrations with haml helpers down to an
incompatibility in content_tag between Rails 2.2 and Haml 2.0.5

When I try rendering this call in my haml view, nothing shows up:

- content_tag :div do
  SHOW ME SOME CONTENT

I tried this both on Haml 2.0.4 and the latest Haml Edge (0a14c3) both
install via plugins. In all cases the content doesnt display.

Here is a test project that demonstrates the problem. Use it with Haml
2.0.4 and Rails 2.2 and you'll see the content doesnt display in Haml.
On Rails 2.1 however, it will work fine.

http://s3.amazonaws.com/railsjedi/hamlbug_rails22.zip

Traced the problem down to the content_tag alias method chaining in
lib/haml/helpers/action_view_mods.rb

I've added a unit test that isolates the bug as well as a fix for the
issue in Rails 2.2. If you are running into this error when using Haml
with Rails 2.2, give it a try. It should resolve your problems.
http://github.com/jcnetdev/haml/commit/bc27e25fcafedb85ce37d818d28721...

Hope this helps. Be great to get a patch for this into 2.0.5 soon
before more Rails 2.2 users run into this issue.

On Nov 19, 11:19 pm, Nathan Weizenbaum <nex...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ashchan  
View profile  
 More options Nov 28 2008, 8:54 am
From: ashchan <ashc...@gmail.com>
Date: Fri, 28 Nov 2008 05:54:14 -0800 (PST)
Local: Fri, Nov 28 2008 8:54 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
div_for seems to be not working either.

On Nov 23, 1:00 pm, railsjedi <jcnet...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdsykes  
View profile  
 More options Nov 28 2008, 2:50 pm
From: sdsykes <sdsy...@gmail.com>
Date: Fri, 28 Nov 2008 11:50:44 -0800 (PST)
Local: Fri, Nov 28 2008 2:50 pm
Subject: Re: View Helpers in Mixed Erb/Haml environment
Yes, this is a very serious bug - it nixes your content tags in rails
2.2.

Before I saw this post I came up with my own fix, but in
capture_with_haml and not in content_tag_with_haml.

This fix is shorter - I just changed line 96 of action_view_mods.rb
from this:

if is_haml?

to this:

block_is_haml =
  begin
    eval('_hamlout', block)
    true
  rescue
    false
  end

if block_is_haml && is_haml?

- Stephen

On Nov 23, 7:00 am, railsjedi <jcnet...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Weizenbaum  
View profile  
 More options Nov 28 2008, 6:44 pm
From: Nathan Weizenbaum <nex...@gmail.com>
Date: Fri, 28 Nov 2008 15:44:44 -0800
Local: Fri, Nov 28 2008 6:44 pm
Subject: Re: [haml] Re: View Helpers in Mixed Erb/Haml environment
This has been fixed in the latest stable. It'll be released as part of
2.0.5 soon.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdsykes  
View profile  
 More options Nov 29 2008, 11:06 am
From: sdsykes <sdsy...@gmail.com>
Date: Sat, 29 Nov 2008 08:06:57 -0800 (PST)
Local: Sat, Nov 29 2008 11:06 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
The problem remains in 2.0.5

This version I can fix just by changing line 89 of action_view_mods.rb
from

if is_haml?

to

if is_haml && block_is_haml?(block)

-Stephen

On Nov 29, 1:44 am, Nathan Weizenbaum <nex...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Weizenbaum  
View profile  
 More options Nov 29 2008, 2:21 pm
From: Nathan Weizenbaum <nex...@gmail.com>
Date: Sat, 29 Nov 2008 11:21:15 -0800
Local: Sat, Nov 29 2008 2:21 pm
Subject: Re: [haml] Re: View Helpers in Mixed Erb/Haml environment
Can you supply a failing test?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdsykes  
View profile  
 More options Nov 30 2008, 5:16 am
From: sdsykes <sdsy...@gmail.com>
Date: Sun, 30 Nov 2008 02:16:40 -0800 (PST)
Local: Sun, Nov 30 2008 5:16 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
Yes.

This is the kind of thing we are doing in our app - try adding this to
helper_test.rb

  class ActionView::Base
    module Ahelper
      def nested_tag
        content_tag(:span) {content_tag(:div) {"something"}}
      end
    end
    include Ahelper
  end

  def test_content_tag_nested
    assert_equal "<span><div>something</div></span>", render("=
nested_tag", :action_view).strip
  end

And this test is fixed by at least by adding '&& block_is_haml?
(block)' to line 89 in action_view_mods.rb, but perhaps you can look
at it in more depth than I have.

-Stephen

On Nov 29, 9:21 pm, Nathan Weizenbaum <nex...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdsykes  
View profile  
 More options Dec 5 2008, 6:00 am
From: sdsykes <sdsy...@gmail.com>
Date: Fri, 5 Dec 2008 03:00:38 -0800 (PST)
Local: Fri, Dec 5 2008 6:00 am
Subject: Re: View Helpers in Mixed Erb/Haml environment
Nathan, did you get a chance to look at this failing test?

-Stephen

On Nov 30, 12:16 pm, sdsykes <sdsy...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Weizenbaum  
View profile  
 More options Dec 6 2008, 11:15 pm
From: Nathan Weizenbaum <nex...@gmail.com>
Date: Sat, 06 Dec 2008 20:15:20 -0800
Local: Sat, Dec 6 2008 11:15 pm
Subject: Re: [haml] Re: View Helpers in Mixed Erb/Haml environment
Okay, I've integrated the test and the fix. This'll go out as Haml 2.0.6
pretty soon.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google