mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Static may be enough
This commit is contained in:
parent
74561f3ee3
commit
c039559f00
3 changed files with 27 additions and 9 deletions
|
@ -1,17 +1,9 @@
|
|||
require 'temple/html/filter'
|
||||
|
||||
# NOTE: This compiler has an extremely bad effect for performance.
|
||||
# We should optimize this.
|
||||
module Hamlit
|
||||
class TextCompiler < Temple::HTML::Filter
|
||||
def on_haml_text(exp)
|
||||
compile_text(exp)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def compile_text(exp)
|
||||
[:dynamic, %Q{"#{exp.gsub(/"/, '\"')}"}]
|
||||
[:static, exp]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,5 +14,20 @@ describe Hamlit::Filters::Css do
|
|||
</style>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'parses string interpolation' do
|
||||
assert_render(<<-HAML, <<-HTML)
|
||||
:css
|
||||
.foo {
|
||||
width: #{100 * 3}px;
|
||||
}
|
||||
HAML
|
||||
<style>
|
||||
.foo {
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,5 +67,16 @@ describe Hamlit::Filters::Javascript do
|
|||
</script>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'parses string interpolation' do
|
||||
assert_render(<<-HAML, <<-HTML)
|
||||
:javascript
|
||||
var a = #{[1, 2]};
|
||||
HAML
|
||||
<script>
|
||||
var a = [1, 2];
|
||||
</script>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue