Evaluating the ERB filter in the template context as well.
This commit is contained in:
parent
491306ce52
commit
a3388f9873
|
@ -564,8 +564,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
|||
#
|
||||
# [erb] Parses the filtered text with ERB, like an RHTML template.
|
||||
# Not available if the <tt>suppress_eval</tt> option is set to true.
|
||||
# At the moment, this doesn't support access to variables
|
||||
# defined by Ruby on Rails or Haml code.
|
||||
# Embedded Ruby code is evaluated in the same context as the Haml template.
|
||||
#
|
||||
# [sass] Parses the filtered text with Sass to produce CSS output.
|
||||
#
|
||||
|
|
|
@ -191,8 +191,9 @@ module Haml
|
|||
include Base
|
||||
lazy_require 'erb'
|
||||
|
||||
def render(text)
|
||||
::ERB.new(text).result(binding)
|
||||
def compile(precompiler, text)
|
||||
src = ::ERB.new(text).src.sub(/^_erbout = '';/, "").gsub("\n", ';')
|
||||
precompiler.send(:push_silent, src)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,26 +36,32 @@ This pre is pretty deeply
 nested.
 Does interpolation work
|
|||
This one is, too.
Nested, that is.


|
||||
</pre>
|
||||
</p>
|
||||
<ul>
|
||||
|
||||
a
|
||||
<li>a</li>
|
||||
|
||||
b
|
||||
<li>b</li>
|
||||
|
||||
c
|
||||
<li>c</li>
|
||||
|
||||
d
|
||||
<li>d</li>
|
||||
|
||||
e
|
||||
<li>e</li>
|
||||
|
||||
f
|
||||
<li>f</li>
|
||||
|
||||
g
|
||||
<li>g</li>
|
||||
|
||||
h
|
||||
<li>h</li>
|
||||
|
||||
i
|
||||
<li>i</li>
|
||||
|
||||
j
|
||||
<li>j</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
<div class='res'>178</div>
|
||||
<ul>
|
||||
<li>Foo</li>
|
||||
<li>Bar</li>
|
||||
|
|
|
@ -52,10 +52,15 @@
|
|||
This one is, too.
|
||||
Nested, that is.
|
||||
|
||||
:erb
|
||||
<% 10.times do |c| %>
|
||||
<%= (c+97).chr %>
|
||||
<% end %>
|
||||
- num = 10
|
||||
%ul
|
||||
:erb
|
||||
<% num.times do |c| %>
|
||||
<li><%= (c+97).chr %></li>
|
||||
<% end %>
|
||||
<% res = 178 %>
|
||||
|
||||
.res= res
|
||||
|
||||
:markdown
|
||||
* Foo
|
||||
|
|
Loading…
Reference in New Issue