Class: Sal::Parser
- Inherits:
-
Object
- Object
- Sal::Parser
- Includes:
- Temple::Mixins::Options
- Defined in:
- lib/sal/parser.rb
Instance Method Summary collapse
-
#call(str) ⇒ Array
Compile the string to a Temple expression.
Instance Method Details
#call(str) ⇒ Array
Compile the string to a Temple expression
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sal/parser.rb', line 13 def call(str) if [:encoding] && str.respond_to?(:encoding) old = str.encoding str = str.dup if str.frozen? str.force_encoding([:encoding]) # Fall back to old encoding if new encoding is invalid str.force_encoding(old_enc) unless str.valid_encoding? end result = [:multi] parse_nodeset([result], Nokogiri::XML(str)) result end |