Ticket #76 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Rendering partials shouldn't print the layout

Reported by: zimbatm Owned by: why
Priority: major Milestone: Camping 1.6
Component: bin/camping Version:
Keywords: Cc:

Description

When you use Ajax, you often want to return just a bunch of html without the layout.

What I propose is that partials won't be rendered with the layout. I also propose that the layout become a partial to make things easier and more logical.

def method_missing(*a,&b)
  a.shift if a[0]==:render
  m=markaby
  s=m.capture{send(*a,&b)}
  s=m.layout{s} if m.respond_to?:layout
  "#{s}"
end

would become :

def method_missing(*a,&b)
  a.shift if a[0]==:render
  m=markaby
  s=m.capture{send(*a,&b)}
  if a[0][0] != _? and m.respond_to?:_layout
    s=m._layout{s}
  end
  "#{s}"
end

Attachments

camping-partials.diff (1.2 kB) - added by zimbatm 2 years ago.
Partials for 20 octet

Change History

follow-up: ↓ 2   Changed 2 years ago by why

  • status changed from new to assigned
  • milestone set to Camping 1.6

Good point, thankyou.

in reply to: ↑ 1 ; follow-up: ↓ 3   Changed 2 years ago by joey

Replying to why:

Good point, thankyou.

Shouldnt it be:

def method_missing(*a,&b)
  a.shift if a[0]==:render
  m=markaby
  s=m.capture{send(*a,&b)}
  if a[0][0] != ?_ and m.respond_to?:_layout
    s=m._layout{s}
  end
  "#{s}"
end

Or maybe the "a[0][0] != ?_" could be "a[0]!~/_/" for shortness!

in reply to: ↑ 2   Changed 2 years ago by joey

Replying to joey: Ooops, that was meant to read:

a[0][0] != ?_

could be

a[0]!~/^_/

for shortness!

  Changed 2 years ago by zimbatm

This won't work with symbols :

a=[:_partial]
a[0]!~/^_/ #=>true

Changed 2 years ago by zimbatm

Partials for 20 octet

  Changed 2 years ago by zimbatm

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in [162]

Note: See TracTickets for help on using tickets.