Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed yield tag

  • Loading branch information...
commit f70db38f4fab1e5381e9b530be64533c901e64d9 1 parent 6a402f2
@pyromaniac pyromaniac authored
View
10 README.md
@@ -50,7 +50,15 @@ In puffer pages you can use puffer pages layouts or applcation layouts.
For puffer pages layouts page parts placeholder is liquid tag yield.
<pre>{% yield [page_part_name] %}</pre>
-If no page_part_name specified, puffer layout will use page part with default name (`body`). You can change defaul page part name in puffer pages setup initializer.
+If no page_part_name specified, puffer layout will use page part with default name ('body'). You can change defaul page part name in puffer pages setup initializer.
+
+Ex.
+<pre>
+ {% yield %} # renders body
+ {% yield 'sidebar' %} # renders sidebar
+ {% assign sb = 'sidebar' %}
+ {% yield sb %} # renders sidebar too
+</pre>
### Application layouts.
For application layout page part body will be inserted instead of SUDDENLY! <%= yield %>
View
2  app/models/page.rb
@@ -99,7 +99,7 @@ def inherited_page_parts
end
def part name
- inherited_page_parts.detect {|part| part.name = name}
+ inherited_page_parts.detect {|part| part.name == name}
end
def is_layout?
View
6 lib/puffer_pages/liquid/tags/yield.rb
@@ -3,20 +3,20 @@ module Liquid
module Tags
class Yield < ::Liquid::Tag
- Syntax = /(\w+)/
+ Syntax = /(#{::Liquid::QuotedFragment}+)/
def initialize(tag_name, markup, tokens)
if markup =~ Syntax
@name = $1
else
- @name = PufferPages.primary_page_part_name
+ @name = "'#{PufferPages.primary_page_part_name}'"
end
super
end
def render(context)
- swallow_nil{context.registers[:page].part(@name).render(context)}
+ context.registers[:page].part(context[@name]).render(context)
end
end
View
4 spec/models/page_spec.rb
@@ -122,9 +122,9 @@
end
it 'should render layout' do
- @layout = Fabricate :layout, :name => 'foo_layout', :body => "{% yield %} {% yield sidebar %}"
+ @layout = Fabricate :layout, :name => 'foo_layout', :body => "|{% yield %}|{% yield 'sidebar' %}|{% assign sb = 'sidebar' %}|{% yield sb %}|"
result = @root.render 'self' => PufferPages::Liquid::PageDrop.new(@root)
- result.should == "#{@root.title} #{@root.name}"
+ result.should == "|#{@root.title}|#{@root.name}||#{@root.name}|"
end
end
View
9 spec/models/tags_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe 'Tags' do
+
+ #describe 'yield' do
+
+ #end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.