public
Description: A library for safe evaluation of Ruby code based on ParseTree/RubyParser and Ruby2Ruby. Provides Rails ActionView template handlers for ERB and Haml.
Homepage: http://www.artweb-design.de
Clone URL: git://github.com/svenfuchs/safemode.git
safemode / lib / action_view / template_handlers / safe_haml.rb
100644 21 lines (18 sloc) 0.511 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'safemode'
require 'haml/safemode'
 
module ActionView
  module TemplateHandlers
    class SafeHaml < TemplateHandler
      include SafemodeHandler
      
      def self.line_offset
      3
      end
 
      def compile(template)
        options = Haml::Template.options.dup
        haml = Haml::Engine.new template, options
        methods = delegate_methods + ActionController::Routing::Routes.named_routes.helpers
        haml.precompile_for_safemode ignore_assigns, methods
      end
    end
  end
end