Doesn't work like that.

First: While it might be possible to add that helper to the relevant
controllers, there's no need to do so: Radiant tags are used in
layouts and snippets instead of ERB syntax. In fact, helper methods
aren't even accessible directly from radius tags, because a "context"
in which radius tags are being evaluated isn't the same as an instance
of a controller class.

So the way to go would be a radius tag used to encode its contents to
b64. See the developer docs for details:

http://wiki.github.com/radiant/radiant/adding-custom-radius-tags

Could be something like this:

<r:base64:encode>
  ... stuff to encode
</r:base64:encode>

or

<r:base64:encode asset="path/to/image/or/whatever" />

HTH. Regards,

Christian

On 11 Aug., 11:00, Martin Stabenfeldt <mar...@stabenfeldt.net> wrote:
> Hi,
>
> I´m planning on creating a helper that can base64 encode images.
> i.e. <%= base64_encode(path_to_image) %>
>
> I started by running script/generate extension base64_encoder
> Then I created
> app/vendor/extension/base64_encoder/app/helpersbase64_encoder_helper.rb:
>
> module Base64EncoderHelper
>
>   def base64_encode
>
>       # .....
>
>   end
>
> end
>
> My base64_encoder_extension.rb looks like this:
>
> class Base64EncoderExtension < Radiant::Extension
>   def activate
>     helper :base64_encoder
>   end
> end
>
> I am however doing something wrong. This is what happens when I reload the
> server:
> radiant/vendor/extensions/base64_encoder/base64_encoder_extension.rb:19:in
> `activate': undefined method `helper' for
> #<Base64EncoderExtension:0x103695330> (NoMethodError)
>         from
> /opt/local/lib/ruby/gems/1.8/gems/radiant-0.9.1/lib/radiant/extension.rb:86:in
> `activate'
>
> How do I get the base64_encode helper available in my views?
>
> Cheers,
> Martin Stabenfeldt

Reply via email to