Sha256: 157f38058e09e0d44a3facc38f7e89512846939b7eb610dde51b9002a4eac8ee

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

module Docx
    module Builder
        module Cleaners
            def self.starting_tags_without_spaces_cleaner(str) 
                str && str.gsub(/\{\s*\{\s*%/, '{{%')
            end
        
            def self.ending_tags_without_spaces_cleaner(str) 
                str && str.gsub(/%\s*\}\s*\}/, '%}}')
            end
        
            def self.single_quote_cleaner(str)
                str && str.gsub(/\‘/, '\'').gsub(/\’/, '\'')
            end
        
            def self.var_without_duplicated_spaces_cleaner(str) 
                str && str.gsub(/\s+/, ' ')
            end
        
            def self.var_without_spaces_inside_brackets_cleaner(str) 
                str && str.gsub(/\[(.*?)\]/) { |match| match.gsub(/\s/, '')}
            end
        
            def self.no_spaces_around_undeline_cleaner(str) 
                str && str.gsub(/\s*\_\s*/, "_")
            end
        
            def self.join_dots_and_brackets_cleaner(str)
                str && str.gsub(/\s*\.\s*/, '.').gsub(/\s*\[\s*/, '[').gsub(/\s*\]/, ']')
            end
        
            def self.question_method_cleaner(str)
                if str && str =~ /\A\{\{\s+if\s*(.*?)\s*\?\s+\}\}\Z/
                    "{{ if #{$1}\? }}"
                else
                    str
                end
            end
        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
docx-builder-0.2.3 lib/docx/builder/cleaners.rb
docx-builder-0.2.2 lib/docx/builder/cleaners.rb
docx-builder-0.2.1 lib/docx/builder/cleaners.rb
docx-builder-0.2.0 lib/docx/builder/cleaners.rb