Re: Rendering of Remote Partials

Jason Roelofs
Mon, 14 May 2007 12:50:55 -0000

Looks good to me. For the removal / parsing of information in the retrieved
HTML, I highly suggest you check out hpricot:
http://code.whytheluckystiff.net/hpricot/

Jason

On 5/12/07, doug <ddjolley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
>
>
> Upon reflection, I decided this whole thing seems to be way too
> complicated
> for what I''m trying to accomplish.  I decided to revisit
Jason''s
> suggestion of
> using wget.  The only problem with it is it''s a bit clumsy and
lacks a
> bit in
> the elegance department.  Then I reasoned that implementing a wget
> method
> in ruby probably isn''t all that difficult.  Upon further
reflection I
> guessed that
> someone had probably already done it.  So, I turned to Google to see
> what
> I could find.  It turns out that this is incredibly easy to
> implement.  So here''s
> the source for my helper method:
>
> def remote_include_partial(url)
>   require ''open-uri''
>   out=""
>   open(url){ |f| out=out+f.read }
> end
>
> I am a neophyte in Ruby programming.  So, if anyone has any
> suggestions
> for improvement, I''d love to hear them.
>
> Including a require within a method seems a bit strange to me; but, I
> don''t
> know how else to do it within the context of a helper.
>
> I''m thinking about expanding the code so that it will work with
both
> remote
> and local partials.  The code would test to see if the url begins with
> ''http:''.
> If it does, it''s remote else it''s local.  If I do that,
I''m wondering
> if there might
> be a better name for the argument now named ''url''.
>
> Sometimes, it''s inconvenient dealing with partials.  It might be
nice
> to have
> them as complete html documents.  So, my second contemplated
> improvement
> would be to optionally allow for removing any beginning content down
> to and
> including any opening and also removing any closing
and
> anything that follows.
>
> Comments on any of the above are most welcome.
>
> Thanks for the input.
>
>        ... doug
>
>
> >