From 072bdda1907c056f78f9252d3c8374cffc965e1f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 24 Dec 2015 01:41:51 +0900 Subject: [PATCH] Optimize string interpolation recursively --- CHANGELOG.md | 1 + lib/hamlit/string_splitter.rb | 2 +- test/hamlit/optimization_test.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baf3a5b6..f64d0cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ project adheres to [Semantic Versioning](http://semver.org/). This change log is ### Added - Optimize inline script inside a tag +- Optimize string interpolation recursively ## [2.1.2](https://github.com/k0kubun/hamlit/compare/v2.1.1...v2.1.2) - 2015-12-16 diff --git a/lib/hamlit/string_splitter.rb b/lib/hamlit/string_splitter.rb index d9171083..36b6e1b1 100644 --- a/lib/hamlit/string_splitter.rb +++ b/lib/hamlit/string_splitter.rb @@ -79,7 +79,7 @@ module Hamlit when :static temple << [:static, content] when :dynamic - temple << [:dynamic, content] + temple << on_dynamic(content) end end temple diff --git a/test/hamlit/optimization_test.rb b/test/hamlit/optimization_test.rb index 441a7ee6..5df6e9b6 100644 --- a/test/hamlit/optimization_test.rb +++ b/test/hamlit/optimization_test.rb @@ -31,5 +31,10 @@ describe 'optimization' do haml = %q|%span= "jruby#{9000}#{dynamic}"| assert_equal true, compiled_code(haml).include?(%|jruby9000|) end + + it 'detects a static part recursively' do + haml = %q|%input{ value: "#{ "hello#{ hello }" }" }| + assert_equal true, compiled_code(haml).include?(%|value='hello|) + end end end