Thanks so much, Nathan. Here's the my edited push_script in case you're
curious...
def push_script(result, tabulation, flattened)
if flattened
result = Haml::Helpers.find_and_preserve (result)
end
unless result.nil?
result = result.to_s.split(/\n/).map do |x|
x =~ /&#/ ? x : SuperRedCloth.new(x).to_html.lite_mode
end.join("\n")
while result[-1] == 10 # \n
# String#chomp is slow
result = result[0...-1]
end
result = result.gsub("\n", "\n#{tabs(tabulation)}")
push_text result, tabulation
end
nil
end
I had to split the result because it's multiline and was RedClothing it
created <br/> everywhere. Heh. I'm still getting odd results [no pun
intended] with this haml though...
%p= "This isn't _just_ a test."
%p This isn't just _another_ test.
SuperRedCloth seems to respond differently than RedCloth does when given a
[Super]RedClothed string. RedCloth doesn't change what's already RedCloth
output whereas SRC adds another <p> [which I removed with lite_mode] and
converts the & in the ’ to & which completely screws up the
output. That regex for &# seems to catch it though.
RSL
On 4/25/07, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
>
> You could probably redefine Haml::Buffer#push_script to do that.
>
> - Nathan
>
> On 4/25/07, Russell Norris <[EMAIL PROTECTED] > wrote:
> >
> > Other than resorting to the :redcloth filter, is there any way to
> > automatically have my strings automatically sent through a helper? Here's
> > what I'm talking about...
> >
> > [helper]
> > def red(string)
> > SuperRedCloth.new (string).to_html.sub /^<p>(.*)<\/p>$/, '\1' # Get
> > rid of that wrapping P element.
> > end
> >
> > [view]
> > %h2 Index Page
> > %p= red "Welcome to [EMAIL PROTECTED] Don't worry if this page doesn't
> > look like you imagined your site looking. It'll soon be customized to meet
> > your needs but for now we're going to use it as a chalkboard where you'll be
> > able to see just how fast and easily you'll be able to update and edit your
> > site."
> > %p= red "If you've looked around the Oyster interface, you've noticed
> > those first four menu items: entries, pages, categories, and tags. Let's
> > look at each of them a little closer."
> >
> > I'd like to not have to put in that "red" call every time. Very undry
> > but the outputted HTML looks better than using the filter :redcloth which
> > seems to indent a little oddly here. Not a huge problem at all just curious
> > if there's a DRYer way than the one I'm doing.
> >
> > RSL
> >
> >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---