embed html files in haml

656 views
Skip to first unread message

Jon Hancock

unread,
Jan 24, 2010, 8:31:23 PM1/24/10
to Haml
I have thousands of html files (simple, all static text) which I need
to embed in haml. Currently, I am getting around the problem by
rendering a page and then doing an AJAX call to get the embedded html
content. This approach is somewhat efficient as I can use send_file
to serve up the embedded content, but there are cases when I can't use
this approach.

I tried this (which I don't see in the haml docs):

%include{ :file => "#{html_file_path}" }

This not work, but it doesn't give me errors either.

Any ideas?
thanks, Jon

Nathan Weizenbaum

unread,
Jan 25, 2010, 12:46:21 AM1/25/10
to ha...@googlegroups.com
I'm not sure why you'd expect that to work... that would just generate an <include> tag, which isn't valid HTML.

If you need to include content in a Haml file, that's the job of Ruby helpers. If you need to load it from static HTML on disk, then you'll probably have to write your own. Where to put these helpers depends on the web framework you're using.


--
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.


Max

unread,
Jan 25, 2010, 12:44:43 PM1/25/10
to Haml
Maybe he was thinking of ESI includes? Though, that wouldn't really
work either without a fair bit of other infrastructure in place...

> > haml+uns...@googlegroups.com <haml%2Bunsu...@googlegroups.com>.

Amy L

unread,
Jan 25, 2010, 3:10:15 PM1/25/10
to ha...@googlegroups.com
Jon do you mean just take the content of an HTML file and throw that into the middle of the output of a Haml file? e.g. like you had Haml rendering a nice outline of the page and the center content was from thousands of pages of medical dictionary entries?

I see a couple of ways you can do this:
  • convert those HTML files into Haml files and store them somewhere in your views directories
  • read the HTML files into a really large string buffer then just echo the content in Haml
  • use an IFRAME
Is this closer to what you're thinking?

The AJAX-to-get-embedded content doesn't seem to be optimal since you're incurring a second HTTP request and more time on the browser to parse the data + you can't cache the entire page now. (My guess is that it was done this way because it "just worked"?)

-- Amy


--
You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages