Skip to content
Snippets Groups Projects
Commit f6805303 authored by Holger Just's avatar Holger Just
Browse files

[#604] Remove the leading newline from Liquid blocks for easier formatting

parent 994132a5
Tags
No related merge requests found
module ChiliProject
module Liquid
module LiquidExt
::Liquid::Block.send(:include, Block)
::Liquid::Context.send(:include, Context)
end
end
......
module ChiliProject
module Liquid
module LiquidExt
module Block
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method_chain :render_all, :cleaned_whitespace
end
end
module InstanceMethods
def render_all_with_cleaned_whitespace(list, context)
# Remove the leading newline in a block's content
list[0].sub!(/\A\r?\n/, "") if list[0].is_a?(String)
render_all_without_cleaned_whitespace(list, context)
end
end
end
end
end
end
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment