A mixin that adds configurable escaping to a tag class.
class MyTag < Inversion::Template::Tag include Inversion::Escaping def render( renderstate ) val = self.get_rendered_value return self.escape( val.to_s, renderstate ) end end
To add a new kind of escaping to Inversion, add a escape_<formatname> method to this module similar to escape_html.
The fallback escape format
Escape the output using the format specified by the given render_state's config.
# File lib/inversion/mixins.rb, line 211 def escape( output, render_state ) format = render_state.options[:escape_format] || DEFAULT_ESCAPE_FORMAT return output if format == :none unless self.respond_to?( "escape_#{format}" ) self.log.error "Format %p not supported. To add support, define a #escape_%s to %s" % [ format, format, __FILE__ ] raise Inversion::OptionsError, "No such escape format %p" % [ format ] end return self.__send__( "escape_#{format}", output ) end
Generated with the Darkfish Rdoc Generator 2.