Is it possible to pass rails variables in the Radiant CMS?

172 Views Asked by At

I'm trying to set up a simple form for a mailing list.

And it doesn't seem to allow any rails helpers to make the form_for and fulfill the authenticity token.

Anyone have any luck installing a simple form_for in Radiant?

1

There are 1 best solutions below

0
On BEST ANSWER

In your /your_extension.rb :

def activate
  Page.send :include, YourCustomTags
end

your_custom_tags.rb

module YourCustomTags
  include Radiant::Taggable

  tag 'custom' do |tag|
    tag.expand
  end

  tag "custom:form" do |tag|
    tag.attr['id'] ||= 'newsletter'
    results = []
    action = "/newsletters/"
    results << %(<form action="#{action}" method="post" #{newsletter_attrs(tag)}>)
    results << %(<input name="authenticity_token" type="hidden" value="#{response.instance_variable_get(:@session)[:_csrf_token]}" />)
    results <<   tag.expand
    results << %(</form>)
  end

This will pass authenticity.