diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2011-02-23 13:37:21 +0900 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2011-02-23 13:37:21 +0900 |
commit | c99e4582731fbe3bfcf95a6905cb30d6a39aa94a (patch) | |
tree | 2fba33600ccbcc1ce737a89fde9cf5192dd4ecc7 /lib | |
parent | 9e9652ff5b1ba430f0f7884e62f1c3be399f707d (diff) | |
download | erubis-c99e4582731fbe3bfcf95a6905cb30d6a39aa94a.tar.gz |
[bugfix] change 'PrefixedLineEnhancer' to be available with command-line option '-E'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erubis/enhancer.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/erubis/enhancer.rb b/lib/erubis/enhancer.rb index 29f5af3..361a582 100644 --- a/lib/erubis/enhancer.rb +++ b/lib/erubis/enhancer.rb @@ -448,11 +448,14 @@ module Erubis def init_generator(properties={}) super - @prefixchar = properties[:prefixchar] || '%' - @prefixrexp = Regexp.compile("^([ \\t]*)\\#{@prefixchar}(.*?\\r?\\n)") + @prefixchar = properties[:prefixchar] end def add_text(src, text) + unless @prefixrexp + @prefixchar ||= '%' + @prefixrexp = Regexp.compile("^([ \\t]*)\\#{@prefixchar}(.*?\\r?\\n)") + end pos = 0 text2 = '' text.scan(@prefixrexp) do @@ -511,9 +514,11 @@ module Erubis #++ def add_text(src, text) - @prefixchar = '%' - @prefixrexp = /^\%(.*?\r?\n)/ - super + unless @prefixrexp + @prefixchar = '%' + @prefixrexp = /^\%(.*?\r?\n)/ + end + super(src, text) end end |