Class: Hanami::View::ERB::Filters::Trimming Private
- Defined in:
- lib/hanami/view/erb/filters/trimming.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Trims spurious spaces from ERB-generated text.
Deletes spaces around “<% %>” and leave spaces around “<%= %>”.
This is a copy of Temple::ERB::Trimming, with the one difference being that it descends into the sexp-tree by running ‘compile(e)` for any non-`:static` sexps. This is necessary for our implementation of ERB, because we capture block content by creating additional `:multi` sexps with their own nested content.
Instance Method Summary collapse
-
#on_multi(*exps) ⇒ Object
private
rubocop:disable Metrics/PerceivedComplexity.
Instance Method Details
#on_multi(*exps) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/PerceivedComplexity
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hanami/view/erb/filters/trimming.rb', line 27 def on_multi(*exps) if [:trim] exps = exps.each_with_index.map do |e, i| if e.first == :static && i > 0 && exps[i - 1].first == :code [:static, e.last.lstrip] elsif e.first == :static && i < exps.size - 1 && exps[i + 1].first == :code [:static, e.last.rstrip] else compile(e) end end end [:multi, *exps] end |