Class: CurrentSnip

Inherits:
Dynasnip show all
Defined in:
lib/vanilla/dynasnips/current_snip.rb

Instance Attribute Summary

Attributes inherited from Vanilla::Renderers::Base

#app

Instance Method Summary collapse

Methods inherited from Dynasnip

all, attribute, build_snip, #method_missing, persist!, persist_all!, snip_attributes, snip_name, usage

Methods inherited from Vanilla::Renderers::Base

escape_curly_braces, #include_snips, #initialize, #prepare, #process_text, #raw_content, render, #render, #render_without_including_snips, snip_regexp

Constructor Details

This class inherits a constructor from Vanilla::Renderers::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dynasnip

Instance Method Details

#handle(*args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vanilla/dynasnips/current_snip.rb', line 16

def handle(*args)
  if args[0] == 'name'
    if app.request.snip_name == 'edit' # we're editing so don't use this name
      app.request.params[:snip_to_edit]
    else
      app.request.snip_name
    end
  else
    if app.request.snip
      app.render(app.request.snip, app.request.part)
    else
      app.response.status = 404
      "Couldn't find snip {link_to #{app.request.snip_name}}"
    end
  end
end