Method: Liquid::BlockBody#remove_blank_strings

Defined in:
lib/liquid/block_body.rb

#remove_blank_stringsObject

Remove blank strings in the block body for a control flow tag (e.g. if, for, case, unless) with a blank body.

For example, in a conditional assignment like the following

“‘ if size > max_size %

{% assign size = max_size %}

endif % “‘

we assume the intention wasn’t to output the blank spaces in the if tag’s block body, so this method will remove them to reduce the render output size.

Note that it is now preferred to use the liquid tag for this use case.



209
210
211
212
# File 'lib/liquid/block_body.rb', line 209

def remove_blank_strings
  raise "remove_blank_strings only support being called on a blank block body" unless @blank
  @nodelist.reject! { |node| node.instance_of?(String) }
end