Inside the Haml filter, you use String interpolation to include Ruby code in your markup. For example:
require 'haml' @x = 42 Haml::Engine.new("%p= @x").render(self) #=> "<p>42</p>\n" Haml::Engine.new(":textile\n\t= @x").render(self) #=> "<p>= @x</p>\n" Haml::Engine.new(":textile\n\t\#{@x}").render(self) #=> "<p>42</p>\n" @content = "alpha\n\n#hi **mom**" Haml::Engine.new(":textile\n\t\#{@content}").render(self) #=> "<p>alpha</p>\n<p>#hi <b>mom</b></p>\n"
Change My previous answer was misleading regarding newlines in the content due to my erroneous testing. As you can see above, newlines in the included content are processed directly.
So your Haml template should look like this:
- @articles.each do |article| %article.post %header=article.name :textile
Note that I removed the %p tag surrounding your markup, as Textile introduces its own paragraph wrappers (even for single-line content).
Phrogz
source share