From: Eric Hodel Date: 2005-03-16T12:55:56+09:00 Subject: Re: eval/binding question --Apple-Mail-23--505849831 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 15 Mar 2005, at 08:17, Stefan Kaes wrote: > when using ERB one can compile a template into source, which can then > be eval'ed using eval. Local variables for use in the template can be > set up using the sort of eval given in my example. However, in this > case the 'compiled' template code gets reparsed on each evaluation of > the template code. I wanted to speed up this process by defining a > function (eval "def fun; #{src}; end", aBinding), thereby pasring the > code only once. ERb already does this for you. See ERB::Defmethod. Unfortunately, there are no docs for it, but you can dig around in Rails to see how it is used. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --Apple-Mail-23--505849831 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCN644MypVHHlsnwQRAqVXAKDpMrfdCwEgWGxAZ7rrBC3nkCtdLwCfekGG Qi0hXNNyvrKWpqLMFfXWpl4= =19Tc -----END PGP SIGNATURE----- --Apple-Mail-23--505849831--