Отправка электронных писем HAML с помощью Pony

Sinatra 1.2.6 / Haml 3.1.2 и Пони

Я получаю "ошибку неправильного количества аргументов (0 вместо 1)", которая указывает на

Синатра/base.rb

def haml(template, options={}, locals={})
  render :haml, template, options, locals
end

Я отправляю :html_body => (haml :html_email) в Pony

Любая помощь будет очень высоко ценится!

M.


person Martin    schedule 08.09.2011    source источник


Ответы (1)


Ваш код работает в Sinatra 1.2.6, Haml 3.1.3 и Pony 1.3. Хотя я бы использовал haml(:test) вместо (haml:test)

тест.rb:

require 'rubygems'
require 'sinatra'
require 'pony'
require 'haml'

set :views, Proc.new { root }

get '/send' do
    options = {
    :to => '[email protected]',
    :from => '[email protected]',
    :subject => 'Test',
    :body => 'Test Text',
    :html_body => (haml :test),
    :via => :smtp,
    :via_options => {
      :address => 'smtp.gmail.com',
      :port => 587,
      :enable_starttls_auto => true,
      :user_name => 'login',
      :password => 'password',
      :authentication => :plain,
      :domain => 'HELO'
    }
  }

  Pony.mail(options)
end

test.haml:

!!!
%html
  %head
    %meta{ :content => "text/html; charset=utf-8", :"http-equiv" => "Content-Type" }
    %title Test
  %body
    %h1 Test
    %p Test content
person dsavickas    schedule 26.10.2011