[prawnto] Changes from Rails 2.1 -> 2.2

1 Aufruf
Direkt zur ersten ungelesenen Nachricht

brady8

ungelesen,
14.11.2008, 02:21:0414.11.08
an Prawn
I've been attempting to get the prawnto working under Rails 2.2.

To start off, I set it up and it gives an "unknown method 'compile'"
error.

So, as far as I can tell between Rails 2.1 -> 2.2, TemplateHandlers
have switched from outputting their template code in a "render"
method, to needing to output code to be compiled in a "compile"
method.

I have no idea why they did this. (I've posted to the Rails Core list
to get an answer, waiting on that).

Prawnto as it stands now doesn't support the compile method, but I'd
like to build that functionality in if possible to support Rails >
2.1. From the github commit logs, it looks like this was tried once
before and "isn't worth the effort".

Moving forward though, it looks like this is the way Rails is going.

So, question is: does anyone know of any resources for Rails 2.2 on
the net that might speak to building a TemplateHandler, and/or
updating the output function from "render" to "compile"?

I'm new to how TemplateHandlers work, but if someone could point me in
the right direction, I'm more than willing to put in the time to get
this to work.

Thanks for your time,
Brady

thorny_sun

ungelesen,
14.11.2008, 05:25:3614.11.08
an Prawn
Haven't looked at this yet, but someone else reported a similar issue.

I wasn't able to find much on the intertubes to help with learning
templates. I just learned everything by reading through the rails
code. The compile mechanism is nice, and I did have prawnto
leveraging it at first-- but then I decided I was wasting too much
time trying to make things work in compile for no benefit. In the
case of prawnto (and xml builder for example) where it is all just
ruby code anyway, there is no real performance gain to be had by
compiling, so I decided to just use the easier development path with
render.

But if render is now completely gone, some options will have to go
away or be given their own extension, such as :dsl option. The
problem is that using the compile method, you've got to create a
string of ruby code to be eval'ed. And if the string itself needs to
change depending on its own evaluation then things get complicated
(i.e. the :dsl option). But this could be solved by just saying you
need to use a .prawndsl extension or whatever. Compiling would also
be nice since it would fix some local variable issues automatically.

If you can wait, I was planning on tackling when rails 2.2 was
officially released (maybe they'll decide to put render back in-- we
can always hope: http://github.com/rails/rails/commit/d2ccb852d4e1f6f1b01e43f32213053ae3bef408#comment_7905)
If you can't wait-- please feel free to submit patches and I will
update the repo. If you go back in the git history to when I was
compiling it may help you figure it all out.

Brady-- if you figure out any more on your end-- do let us know-- we
can just keep adding to this thread..

good luck,
-thorny_sun

brady8

ungelesen,
14.11.2008, 15:30:4914.11.08
an Prawn
I've built very basic support for Rails 2.2 using compiled templates,
thanks to advice and help from both thorny-sun and Josh Peek on the
Rails Core list.

Options passed to Prawn work as usual, but the "dsl" option does not,
as well as any modifications to the response headers (content-
disposition, cache-control, etc.) On a related note, compiled
templates are (at least for me) confusing as hell, and for the life of
me I couldn't figure out how to access the view.

Patch for thorny-sun's repo (if he chooses to apply it) is located
here: http://gist.github.com/25073

Regards,
Brady

On Nov 14, 3:25 am, thorny_sun <michael.pr...@gmail.com> wrote:
> Haven't looked at this yet, but someone else reported a similar issue.
>
> I wasn't able to find much on the intertubes to help with learning
> templates.  I just learned everything by reading through the rails
> code.  The compile mechanism is nice, and I did have prawnto
> leveraging it at first-- but then I decided I was wasting too much
> time trying to make things work in compile for no benefit.  In the
> case of prawnto (and xml builder for example) where it is all just
> ruby code anyway, there is no real performance gain to be had by
> compiling, so I decided to just use the easier development path with
> render.
>
> But if render is now completely gone, some options will have to go
> away or be given their own extension, such as :dsl option.  The
> problem is that using the compile method, you've got to create a
> string of ruby code to be eval'ed.  And if the string itself needs to
> change depending on its own evaluation then things get complicated
> (i.e. the :dsl option).  But this could be solved by just saying you
> need to use a .prawndsl extension or whatever.  Compiling would also
> be nice since it would fix some local variable issues automatically.
>
> If you can wait, I was planning on tackling when rails 2.2 was
> officially released (maybe they'll decide to put render back in-- we
> can always hope:http://github.com/rails/rails/commit/d2ccb852d4e1f6f1b01e43f32213053a...)

brady8

ungelesen,
25.11.2008, 17:47:2725.11.08
an Prawn
So, good news! It looks like as of the current Edge (2.3) Rails, they
have added back in support for rendered templates, with a few minor
changes.

I've updated my fork of thorny-sun's prawnto repo accordingly to work
with 2.3/edge.

-Brady
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten