summaryrefslogtreecommitdiff
path: root/lib/erubis/enhancer.rb
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2006-07-27 01:31:03 +0000
committermakoto kuwata <kwa@kuwata-lab.com>2006-07-27 01:31:03 +0000
commit64f2c1b50e888e7d420c02a3ee56f6cfc8226106 (patch)
tree7ccf3667dae85f5bec87423e5967d20218b6bab1 /lib/erubis/enhancer.rb
parentce9cf465cced27a076ad0523b23c176709034a03 (diff)
downloaderubis-64f2c1b50e888e7d420c02a3ee56f6cfc8226106.tar.gz
- [refactor] untabify() function is improved to use String#split() instead of String#scan()
- [refactor] Engine#compile() is improved by scanning regexp tuning
Diffstat (limited to 'lib/erubis/enhancer.rb')
-rw-r--r--lib/erubis/enhancer.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/erubis/enhancer.rb b/lib/erubis/enhancer.rb
index a6f084a..6bb2940 100644
--- a/lib/erubis/enhancer.rb
+++ b/lib/erubis/enhancer.rb
@@ -319,14 +319,18 @@ module Erubis
"get compile faster but leave spaces around '<% %>'"
end
- #DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
- SIMPLE_REGEXP = /(.*?)<%(=+|\#)?(.*?)-?%>/m
+ #DEFAULT_REGEXP = /(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
+ SIMPLE_REGEXP = /<%(=+|\#)?(.*?)-?%>/m
def compile(input)
src = ""
add_preamble(src)
#regexp = pattern_regexp(@pattern)
- input.scan(SIMPLE_REGEXP) do |text, indicator, code|
+ pos = 0
+ input.scan(SIMPLE_REGEXP) do |indicator, code|
+ index = Regexp.last_match.begin(0)
+ text = input[pos, index - pos]
+ pos = index + $&.length()
add_text(src, text)
if !indicator # <% %>
add_stmt(src, code)