Class: Temple::Filters::RemoveBOM

Inherits:
Parser show all
Defined in:
lib/temple/filters/remove_bom.rb

Overview

Remove BOM from input string

Constant Summary

Constants included from Utils

Utils::ESCAPE_HTML, Utils::ESCAPE_HTML_PATTERN

Instance Attribute Summary

Attributes included from Mixins::Options

#options

Instance Method Summary collapse

Methods included from Mixins::Options

included, #initialize

Methods included from Utils

#empty_exp?, #escape_html, #escape_html_safe, #indent_dynamic, #unique_name

Instance Method Details

#call(s) ⇒ Object



8
9
10
11
# File 'lib/temple/filters/remove_bom.rb', line 8

def call(s)
  return s if s.encoding.name !~ /^UTF-(8|16|32)(BE|LE)?/
  s.gsub(Regexp.new("\\A\uFEFF".encode(s.encoding.name)), ''.freeze)
end