diff options
Diffstat (limited to 'lib/banzai/filter/truncate_source_filter.rb')
-rw-r--r-- | lib/banzai/filter/truncate_source_filter.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/banzai/filter/truncate_source_filter.rb b/lib/banzai/filter/truncate_source_filter.rb new file mode 100644 index 00000000000..c903b83d868 --- /dev/null +++ b/lib/banzai/filter/truncate_source_filter.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Banzai + module Filter + class TruncateSourceFilter < HTML::Pipeline::TextFilter + def call + return text unless context.key?(:limit) + + text.truncate_bytes(context[:limit]) + end + end + end +end |