Using RoR to produce .xhtml files

How can I manipulate RoR to produce an .xhtml file from the view
template(s)? I see how I can use layouts and paritals to efficiently
produce the content and tags that I need, but how can I get the actual
file that’s produced to be named with the .xhtml suffix, (rather than
*.htm, as it currently is)? [Note: I never thought the suffix was all
that important, but evidenly Mozilla won’t behave in some cases unless
the files is named with the xhtml suffix.]

thanks,
Alex

What??
Make sure your output validates and contains the correct doctype. I’ve
never
heard of such a thing. If this is true, I’d love to know more about it.

Well, I made some changes, and now the output is validating when saved
as an .xhtml file, and “tenatively validating” (“no character encoding
found”) when the identical file is saved as .html.

Still, the .xhtml page renders perfectly in Mozilla, but the .html page
does not. (I’m using MathML to display some equations, and these are
the problems spots – MathML only seems to work if the file has an
.xhtml suffix.)

Regardless, there must be some way to tailer RoR to a specific output
file extension. No?

Thanks so much.

Brian H. wrote:

What??
Make sure your output validates and contains the correct doctype. I’ve
never
heard of such a thing. If this is true, I’d love to know more about it.

On Fri, 14 Jul 2006, Alex A. wrote:

Still, the .xhtml page renders perfectly in Mozilla, but the .html page
does not. (I’m using MathML to display some equations, and these are
the problems spots – MathML only seems to work if the file has an
.xhtml suffix.)

My experience was that if the .html was served with the correct doctype
as
application/xhtml+xml that MathML worked, but this was some time ago.

See: http://www.w3.org/TR/xhtml-media-types/

To answer your question, you can set URL rewriting (including
adding .xhtml to the end) using routes.
http://manuals.rubyonrails.com/read/chapter/65

However, I agree with your other responders that you shouldn’t need
to do this, and it’s better to keep the URLs clean and without
extensions.
http://www.w3.org/Provider/Style/URI

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

Alex A. wrote:

Well, I made some changes, and now the output is validating when saved
as an .xhtml file, and “tenatively validating” (“no character encoding
found”) when the identical file is saved as .html.

You set the encoding in the http headers, easy to do w/ a filter in the
app controller. Here’s a ref:
http://wiki.rubyonrails.com/rails/pages/HowtoSetDefaultEncoding

Still, the .xhtml page renders perfectly in Mozilla, but the .html page
does not. (I’m using MathML to display some equations, and these are
the problems spots – MathML only seems to work if the file has an
.xhtml suffix.)

Regardless, there must be some way to tailer RoR to a specific output
file extension. No?

Try URL rewriting in your webserver, or hacking around in routes.rb.
But you really shouldn’t need to do this. Have you set the doctype
correctly in your layout/views?

There’s reference info on how to declare the processing instructions for
docs with MathML, have you seen:
http://www.w3.org/Math/XSL/

cheers,
phil

Everyone, thanks so much. This has been invaluably helpful. Thanks so
much for your patience and assistance.

Dan K. wrote:

To answer your question, you can set URL rewriting (including
adding .xhtml to the end) using routes.
http://manuals.rubyonrails.com/read/chapter/65

However, I agree with your other responders that you shouldn’t need
to do this, and it’s better to keep the URLs clean and without
extensions.
http://www.w3.org/Provider/Style/URI

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs