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


|
This one is, too.
Nested, that is.


|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</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>
|
<ul>
|
||||||
<li>Foo</li>
|
<li>Foo</li>
|
||||||
<li>Bar</li>
|
<li>Bar</li>
|
||||||
|
|
|
@ -52,10 +52,15 @@
|
||||||
This one is, too.
|
This one is, too.
|
||||||
Nested, that is.
|
Nested, that is.
|
||||||
|
|
||||||
:erb
|
- num = 10
|
||||||
<% 10.times do |c| %>
|
%ul
|
||||||
<%= (c+97).chr %>
|
:erb
|
||||||
<% end %>
|
<% num.times do |c| %>
|
||||||
|
<li><%= (c+97).chr %></li>
|
||||||
|
<% end %>
|
||||||
|
<% res = 178 %>
|
||||||
|
|
||||||
|
.res= res
|
||||||
|
|
||||||
:markdown
|
:markdown
|
||||||
* Foo
|
* Foo
|
||||||
|
|
Loading…
Reference in New Issue