I'm trying to use Textile and ERB together for a website I'm
developing. Basically, a sample file looks like:
···
---
<%= produce_some_output "param" %>
Here's some *Textile* text.
---
I want the ERB code to be evaluated and I also want the Textile markup
translated into HTML. How can I do this? Right now I'm doing:
s = File.read "myfile.rhtml"
result = RedCloth.new(ERB.new(s).result).to_html
The problem is that the produce_some_output function prints out the
opening <html>, <body>, and <head> tags. RedCloth surrounds this with
<p> tags and thus prevents the page from rendering properly. I tried
running ERB after RedCloth, but RedCloth converted the quotes in the
ERB code to HTML entities.
How can I make this work?
Bill Atkins
This is really the problem, right? Who wrote the produce_some_output
method? There doesn't appear to be an inherent problem with
comingling erb and RedCloth. You would have the same problem if you
replaced the call to produce_some_output with embedded <html>, <body>,
and <head> tags. Maybe I'm misunderstanding.
If you can't change the produce_some_output method to have it stop
returning the unwanted HTML tags, then you could hack the HTML tags
out with gsub, or (more accurate--more of a pain) use something like
the ruby htmltools library to properly parse the output and return
only the sub-nodes you want. Yuck. 
Chad
···
On Wed, 20 Oct 2004 11:28:42 +0900, Bill Atkins <batkins57@gmail.com> wrote:
I'm trying to use Textile and ERB together for a website I'm
developing. Basically, a sample file looks like:
---
<%= produce_some_output "param" %>
Here's some *Textile* text.
---
I want the ERB code to be evaluated and I also want the Textile markup
translated into HTML. How can I do this? Right now I'm doing:
s = File.read "myfile.rhtml"
result = RedCloth.new(ERB.new(s).result).to_html
The problem is that the produce_some_output function prints out the
opening <html>, <body>, and <head> tags.
Gosh. The problem was indeed in the produce_some_output method.
Thanks.
I need to start thinking about problems more thoroughly before posting
them here.
Bill
···
On Wed, 20 Oct 2004 12:51:10 +0900, Chad Fowler <chadfowler@gmail.com> wrote:
This is really the problem, right? Who wrote the produce_some_output
method? There doesn't appear to be an inherent problem with
comingling erb and RedCloth. You would have the same problem if you
replaced the call to produce_some_output with embedded <html>, <body>,
and <head> tags. Maybe I'm misunderstanding.
I spoke too soon. I'm still having the problem. Even if i replace
the method call with <%= "<html>\n\ntext" %> it gets wrapped in <p>'s.
I was trying to avoid the gsub solution, but that's looking like my
best bet right now. Hmm.
Bill
···
On Tue, 19 Oct 2004 23:56:07 -0400, Bill Atkins <batkins57@gmail.com> wrote:
Gosh. The problem was indeed in the produce_some_output method.
Thanks.
I need to start thinking about problems more thoroughly before posting
them here.
Bill
On Wed, 20 Oct 2004 12:51:10 +0900, Chad Fowler <chadfowler@gmail.com> wrote:
> This is really the problem, right? Who wrote the produce_some_output
> method? There doesn't appear to be an inherent problem with
> comingling erb and RedCloth. You would have the same problem if you
> replaced the call to produce_some_output with embedded <html>, <body>,
> and <head> tags. Maybe I'm misunderstanding.
Bill Atkins wrote:
Gosh. The problem was indeed in the produce_some_output method.
Thanks.
I need to start thinking about problems more thoroughly before posting
them here.
Oh, not to worry. I've long ago discovered that the fastest way to find a simple bug is to hit the 'send' button.
James
OK, my solution (for anyone who's interested) was to put all textile
code between <textile>...</textile> blocks and then just transform the
text between the <textile> delimiters.
Bill
···
On Wed, 20 Oct 2004 00:05:31 -0400, Bill Atkins <batkins57@gmail.com> wrote:
I spoke too soon. I'm still having the problem. Even if i replace
the method call with <%= "<html>\n\ntext" %> it gets wrapped in <p>'s.
I was trying to avoid the gsub solution, but that's looking like my
best bet right now. Hmm.
Bill
On Tue, 19 Oct 2004 23:56:07 -0400, Bill Atkins <batkins57@gmail.com> wrote:
> Gosh. The problem was indeed in the produce_some_output method.
Thanks.
>
> I need to start thinking about problems more thoroughly before posting
> them here.
>
> Bill
>
>
>
>
> On Wed, 20 Oct 2004 12:51:10 +0900, Chad Fowler <chadfowler@gmail.com> wrote:
> > This is really the problem, right? Who wrote the produce_some_output
> > method? There doesn't appear to be an inherent problem with
> > comingling erb and RedCloth. You would have the same problem if you
> > replaced the call to produce_some_output with embedded <html>, <body>,
> > and <head> tags. Maybe I'm misunderstanding.
>