Thanks seth,
That looks promising, although a bit weird with the ::Shoes thing. I'll
play with that a bit and see how it works. The best thing I could come up
with was a proxy class. like this:
Class SharedCode
def initialize(app)
@app = app
end
def header
para "header"
end
def method_missing(meth, *args, &block)
@app.send(meth, *args, &block)
end
end
this breaks down of course for links because the urls are out of scope. :(
also it is annoying to have to refer to the header method via an instance of
another class. So not really much of a solution there.
Even if your solution works I strongly agree that it would be nice for these
classes to behave normally. I always end up with convenience methods for
frequently used styles and such that should be useable on other windows.
On Sun, Nov 2, 2008 at 12:32 AM, Seth Thomas Rasmussen <
[EMAIL PROTECTED]> wrote:
> On Sun, Nov 2, 2008 at 1:59 AM, Josh Cronemeyer
> <[EMAIL PROTECTED]> wrote:
> > Basic usage question follows:
> >
> > #!/usr/bin/env open -a Shoes.app
> > class Examplish < Shoes
> >
> > url "/", :index
> > url "/new", :new_window
> >
> >
> > def index
> > header
> > para link "make a new window", :click => "/new"
> >
> > end
> >
> > def new_window
> > window do
> > header
> > para "a new window"
> >
> > end
> > end
> >
> > def header
> > para "header"
> > end
> >
> > end
> > Shoes.app
> >
> >
> > In the above code the header method is not available inside of the window
> > block. Is there a good way to make a method from the parent window
> > available on the child?
>
> I dunno if it's good, but this seems to work:
>
> #!/usr/bin/env open -a Shoes.app
>
> class ::Shoes
> def header
> para "header"
> end
> end
>
> class Examplish < Shoes
> url "/", :index
> url "/new", :new_window
>
> def index
> header
> para link "make a new window", :click => "/new"
> end
>
> def new_window
> window do
> header
> para "a new window"
> end
> end
> end
>
> Shoes.app
>
> ###
>
> It seems that window() creates a new instance of a Shoes app or
> something which somehow has no understanding of the app which spawned
> it.
>
> Note that if you say "class Shoes" without the leading "::" the app
> somehow ends up not knowing what "url" means. At least that's what I
> found just now with "shoes raisins (0.r1064) [i686-darwin8.9.1]".
>
> The unusual context within which the main file is executed seems to
> continually be a problem. It would be nice for it to behave like a
> normal person.
>
> --
> Seth Thomas Rasmussen
> http://greatseth.com
>