Module: ActionTree::Components::Tilt::Helpers
- Defined in:
- lib/action_tree/components/tilt.rb
Instance Method Summary collapse
-
#render(*args, &blk) ⇒ Object
Public: Renders a template.
Instance Method Details
#render(*args, &blk) ⇒ Object
Public: Renders a template
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/action_tree/components/tilt.rb', line 41 def render(*args, &blk) tilt = args.find {|a| a.is_a?(Tilt::Template) } name = args.find {|a| a.is_a?(Symbol) } source = args.find {|a| a.is_a?(String) } = args.find {|a| a.is_a?(Hash) } if tilt && source path = File.join(config[:template_path], source) tilt = Tilt.new(path, nil, ) end templates = @_match.templates[name] default :type, templates.first.class.default_mime_type result = tilt ? tilt.render(self, , &blk) : nil templates.reverse.inject(result) do |r, template| template.render(self) { r } end end |