Sinatra 1.2.6 / Haml 3.1.2 和 Pony
我收到“错误数量的参数错误(0 代表 1)”,它指向
sinatra/base.rb
def haml(template, options={}, locals={})
render :haml, template, options, locals
end
我正在发送 :html_body => (haml :html_email) 给 Pony
任何帮助将不胜感激!
M。
您的代码似乎适用于 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 => 'user@gmail.com',
:from => 'user@gmail.com',
: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
测试.haml:
!!!
%html
%head
%meta{ :content => "text/html; charset=utf-8", :"http-equiv" => "Content-Type" }
%title Test
%body
%h1 Test
%p Test content