aynı şeyi öğrenmek için çalışıyordu ve çok ERB ve diğer şablon sistemleri sarar Tilt gem kullanarak dışındaki tatmin edici olduğunu bulamadık ve aka (blokları geçen destekler, ayrı sonuçları işlemek biraz daha hoş olabilir. senin yakut çağrısı
template = Tilt::ERBTemplate.new("layout.erb")
File.open "other_template.html" do |file|
file.write template.render(context) {
Tilt::ERBTemplate.new("other_template.erb").render
}
end
O yield
vücuda other_template
sonuçlarını uygulanacaktır içinde
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title><%= title %></title>
</head>
<body>
<%= yield %>
</body>
</html>
Sonra https://code.tutsplus.com/tutorials/ruby-for-newbies-the-tilt-gem--net-20027
layout.erb:
Görülme.
Olası http://stackoverflow.com/a/2467313/772874 kopyasının kopyası Bunun için ActionView'a ihtiyacınız var. –