Module: Erubis::SimplifyEnhancer
- Included in:
- PrintOutSimplifiedEruby, SimplifiedEruby, StdoutSimplifiedEruby
- Defined in:
- lib/erubis/enhancer.rb
Overview
get convert faster, but spaces around ‘<%…%>’ are not trimmed.
this is language-independent.
Constant Summary collapse
- SIMPLE_REGEXP =
DEFAULT_REGEXP = /(^[ t]*)?<%(=+|#)?(.*?)-?%>([ t]*r?n)?/m
/<%(=+|\#)?(.*?)-?%>/m
Class Method Summary collapse
-
.desc ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.desc ⇒ Object
:nodoc:
336 337 338 |
# File 'lib/erubis/enhancer.rb', line 336 def self.desc # :nodoc: "get convert faster but leave spaces around '<% %>'" end |
Instance Method Details
#convert(input) ⇒ Object
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/erubis/enhancer.rb', line 343 def convert(input) src = "" add_preamble(src) #regexp = pattern_regexp(@pattern) pos = 0 input.scan(SIMPLE_REGEXP) do |indicator, code| match = Regexp.last_match index = match.begin(0) text = input[pos, index - pos] pos = match.end(0) add_text(src, text) if !indicator # <% %> add_stmt(src, code) elsif indicator[0] == ?\# # <%# %> n = code.count("\n") add_stmt(src, "\n" * n) else # <%= %> add_expr(src, code, indicator) end end rest = $' || input add_text(src, rest) add_postamble(src) return src end |