puffer_pages 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -2
- data/README.md +19 -24
- data/VERSION +1 -1
- data/app/models/page.rb +2 -2
- data/app/models/page_part.rb +3 -3
- data/app/models/snippet.rb +0 -10
- data/lib/puffer_pages.rb +1 -2
- data/lib/puffer_pages/liquid/file_system.rb +28 -0
- data/lib/puffer_pages/liquid/page_drop.rb +29 -8
- data/puffer_pages.gemspec +4 -2
- data/spec/lib/drops_spec.rb +49 -0
- data/spec/lib/tags_spec.rb +10 -15
- data/spec/models/page_spec.rb +1 -1
- metadata +6 -4
- data/lib/puffer_pages/liquid/tags/render_snippet.rb +0 -33
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/tobi/liquid.git
|
3
|
+
revision: 7bbb4ff84f192a6a2292e8bf16e1049cad34d763
|
4
|
+
specs:
|
5
|
+
liquid (2.2.2)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: http://rubygems.org/
|
3
9
|
specs:
|
@@ -65,7 +71,6 @@ GEM
|
|
65
71
|
git (>= 1.2.5)
|
66
72
|
rake
|
67
73
|
json_pure (1.5.1)
|
68
|
-
liquid (2.2.2)
|
69
74
|
mail (2.2.15)
|
70
75
|
activesupport (>= 2.3.6)
|
71
76
|
i18n (>= 0.4.0)
|
@@ -146,7 +151,7 @@ DEPENDENCIES
|
|
146
151
|
fabrication (= 0.9.2)
|
147
152
|
forgery
|
148
153
|
jeweler
|
149
|
-
liquid
|
154
|
+
liquid!
|
150
155
|
mongrel
|
151
156
|
mysql
|
152
157
|
nested_set
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Warning! This puffer_pages version requires liquid from repo. So, add following line to your Gemfile until new liquid version will release.
|
2
|
+
<pre>gem 'liquid', :git => 'git://github.com/tobi/liquid.git'</pre>
|
3
|
+
|
1
4
|
# Puffer_pages is lightweight rails 3 CMS
|
2
5
|
|
3
6
|
Interface of pages based on [puffer](https://github.com/puffer/puffer)
|
@@ -44,20 +47,19 @@ Puffer_pages use liquid as template language.
|
|
44
47
|
## Pages
|
45
48
|
Pages - tree-based structure of site.
|
46
49
|
Every page has one or more page parts.
|
47
|
-
Every page part must have main page part, named by default `body`. You can configure main page part name in config/initializers/puffer_pages.rb
|
48
50
|
|
49
51
|
## PageParts
|
50
|
-
Page_parts are the same as content_for block in rails. You can insert current page page_patrs at layout.
|
52
|
+
Page_parts are the same as content_for block content in rails. You can insert current page page_patrs at layout.
|
51
53
|
Also, page_parts are inheritable. It means, that if root has page_part named `sidebar`, all its children will have the same page_part until this page_part will be redefined.
|
54
|
+
Every page part must have main page part, named by default `body`. You can configure main page part name in config/initializers/puffer_pages.rb
|
52
55
|
|
53
56
|
## Layouts
|
54
57
|
Layout is page canvas, so you can draw page parts on it.
|
55
|
-
You can use layouts from database or applcation for pages.
|
58
|
+
You can use layouts from database or rails applcation layouts for pages.
|
56
59
|
|
57
|
-
###
|
60
|
+
### Rails application layouts
|
58
61
|
For application layout page_part body will be inserted instead of SUDDENLY! <%= yield %>
|
59
|
-
|
60
|
-
See `yield` liquid tag reference
|
62
|
+
For yield with no parans specified puffer will use page part with default page_part name.
|
61
63
|
|
62
64
|
So, main page part is action view and other are partials. So easy.
|
63
65
|
|
@@ -72,29 +74,22 @@ This variables accessible from every page:
|
|
72
74
|
<pre>{{ root.name }}</pre>
|
73
75
|
Both `self` and `root` are instances of page drop. View [this](https://github.com/puffer/puffer_pages/blob/master/lib/puffer_pages/liquid/page_drop.rb) to find list of possible page drop methods
|
74
76
|
|
75
|
-
###
|
76
|
-
|
77
|
-
`yield` tag is page part or actionview `content_for` placeholder.
|
78
|
-
|
79
|
-
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.
|
77
|
+
### include
|
78
|
+
`include` is standart liquid tag with pudder data model 'file_system'
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
{% yield 'sidebar' %} # renders sidebar
|
85
|
-
{% assign sb = 'sidebar' %}
|
86
|
-
{% yield sb %} # renders sidebar too
|
87
|
-
</pre>
|
80
|
+
#### for page_parts
|
81
|
+
Use include tag for current page page_parts inclusion:
|
82
|
+
<pre>{% include 'page_part_name' %}</pre>
|
88
83
|
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
#### for snippets
|
85
|
+
To include snippet use this path form:
|
86
|
+
<pre>{% include 'snippets/snippet_name' %}</pre>
|
92
87
|
|
93
88
|
Usage example:
|
94
89
|
<pre>
|
95
|
-
{%
|
96
|
-
{% assign
|
97
|
-
{%
|
90
|
+
{% include 'sidebar' %} # this will render 'sidebar' page_part
|
91
|
+
{% assign navigation = 'snippets/navigation' %}
|
92
|
+
{% include navigation %} # this will render 'navigation' snippet
|
98
93
|
</pre>
|
99
94
|
|
100
95
|
### stylesheets, javascripts
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/app/models/page.rb
CHANGED
@@ -68,9 +68,9 @@ class Page < ActiveRecord::Base
|
|
68
68
|
def render(drops_or_context)
|
69
69
|
if inherited_layout
|
70
70
|
@template = Liquid::Template.parse(inherited_layout.body)
|
71
|
-
tracker.cleanup @template.render(drops_or_context, :registers => {:tracker => tracker, :page => self})
|
71
|
+
tracker.cleanup @template.render(drops_or_context, :registers => {:tracker => tracker, :page => self, :file_system => PufferPages::Liquid::FileSystem.new})
|
72
72
|
else
|
73
|
-
inherited_page_parts.map{|part| part.render(drops_or_context,
|
73
|
+
inherited_page_parts.map{|part| part.render(drops_or_context, self)}.join
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
data/app/models/page_part.rb
CHANGED
@@ -4,10 +4,10 @@ class PagePart < ActiveRecord::Base
|
|
4
4
|
validates_presence_of :name
|
5
5
|
validates_uniqueness_of :name, :scope => :page_id
|
6
6
|
|
7
|
-
def render(drops_or_context,
|
7
|
+
def render(drops_or_context, page = nil)
|
8
8
|
template = Liquid::Template.parse(body)
|
9
|
-
result = tracker.cleanup template.render(drops_or_context,
|
10
|
-
main? ? result :
|
9
|
+
result = tracker.cleanup template.render(drops_or_context, :registers => {:tracker => tracker, :page => page, :file_system => PufferPages::Liquid::FileSystem.new})
|
10
|
+
main? ? result : "<% content_for :#{name} do %>#{result}<% end %>"
|
11
11
|
end
|
12
12
|
|
13
13
|
def tracker
|
data/app/models/snippet.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
class Snippet < ActiveRecord::Base
|
2
2
|
validates_presence_of :name
|
3
3
|
validates_uniqueness_of :name
|
4
|
-
|
5
|
-
def render(drops_or_context)
|
6
|
-
template = Liquid::Template.parse(body)
|
7
|
-
tracker.cleanup template.render(drops_or_context, :registers => {:tracker => tracker})
|
8
|
-
end
|
9
|
-
|
10
|
-
def tracker
|
11
|
-
@tracker ||= PufferPages::Liquid::Tracker.new
|
12
|
-
end
|
13
|
-
|
14
4
|
end
|
data/lib/puffer_pages.rb
CHANGED
@@ -19,8 +19,7 @@ require 'nested_set'
|
|
19
19
|
require 'puffer_pages/engine'
|
20
20
|
require 'puffer_pages/extensions/core'
|
21
21
|
require 'puffer_pages/extensions/mapper'
|
22
|
-
require 'puffer_pages/liquid/tags/yield'
|
23
|
-
require 'puffer_pages/liquid/tags/render_snippet'
|
22
|
+
#require 'puffer_pages/liquid/tags/yield'
|
24
23
|
require 'puffer_pages/liquid/tags/stylesheets'
|
25
24
|
require 'puffer_pages/liquid/tags/javascripts'
|
26
25
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module PufferPages
|
2
|
+
module Liquid
|
3
|
+
class FileSystem < ::Liquid::BlankFileSystem
|
4
|
+
|
5
|
+
def read_template_file(context, template_name)
|
6
|
+
template_path = context[template_name]
|
7
|
+
|
8
|
+
case template_type template_path
|
9
|
+
when :snippet then
|
10
|
+
template_path = template_path.gsub(/^snippets\//, '')
|
11
|
+
snippet = Snippet.find_by_name(template_path)
|
12
|
+
raise FileSystemError, "No such snippet '#{template_path}' found" unless snippet
|
13
|
+
snippet.body
|
14
|
+
when :page_part then
|
15
|
+
page_part = context.registers[:page].part(template_path)
|
16
|
+
raise FileSystemError, "No such page_part '#{template_path}' found for current page" unless page_part
|
17
|
+
page_part.body
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def template_type template_path
|
22
|
+
return :snippet if template_path.start_with? 'snippets/'
|
23
|
+
return :page_part
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -2,40 +2,61 @@ module PufferPages
|
|
2
2
|
module Liquid
|
3
3
|
class PageDrop < ::Liquid::Drop
|
4
4
|
|
5
|
+
include ActionController::UrlFor
|
6
|
+
include Rails.application.routes.url_helpers
|
7
|
+
|
5
8
|
def initialize page, request = nil
|
6
9
|
@page, @request = page, request
|
7
10
|
end
|
8
11
|
|
9
12
|
(%w(name title description keywords created_at updated_at) + Page.statuses.map{|s| "#{s}?"}).each do |attribute|
|
10
13
|
define_method attribute do
|
11
|
-
|
14
|
+
page.send(attribute)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def parent
|
16
|
-
@parent ||= self.class.new(
|
19
|
+
@parent ||= self.class.new(page.parent, @request)
|
17
20
|
end
|
18
21
|
|
19
|
-
%w(children
|
22
|
+
%w(ancestors children).each do |attribute|
|
20
23
|
define_method attribute do
|
21
|
-
instance_variable_get("@#{attribute}") || instance_variable_set("@#{attribute}",
|
24
|
+
instance_variable_get("@#{attribute}") || instance_variable_set("@#{attribute}", page.send(attribute).map{ |ac| self.class.new(ac, request)})
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
28
|
def ancestors?
|
26
|
-
|
29
|
+
!page.root?
|
27
30
|
end
|
28
31
|
|
29
32
|
def children?
|
30
|
-
|
33
|
+
page.children.present?
|
31
34
|
end
|
32
35
|
|
33
36
|
def path
|
34
|
-
|
37
|
+
puffer_page_path page.location
|
35
38
|
end
|
36
39
|
|
37
40
|
def url
|
38
|
-
|
41
|
+
puffer_page_url page.location
|
42
|
+
end
|
43
|
+
|
44
|
+
def current?
|
45
|
+
path == request.path_info
|
46
|
+
end
|
47
|
+
|
48
|
+
def ancestor?
|
49
|
+
request.path_info.start_with? path
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def request
|
55
|
+
@request
|
56
|
+
end
|
57
|
+
|
58
|
+
def page
|
59
|
+
@page
|
39
60
|
end
|
40
61
|
|
41
62
|
end
|
data/puffer_pages.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{puffer_pages}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["pyromaniac"]
|
@@ -62,9 +62,9 @@ Gem::Specification.new do |s|
|
|
62
62
|
"lib/puffer_pages/engine.rb",
|
63
63
|
"lib/puffer_pages/extensions/core.rb",
|
64
64
|
"lib/puffer_pages/extensions/mapper.rb",
|
65
|
+
"lib/puffer_pages/liquid/file_system.rb",
|
65
66
|
"lib/puffer_pages/liquid/page_drop.rb",
|
66
67
|
"lib/puffer_pages/liquid/tags/javascripts.rb",
|
67
|
-
"lib/puffer_pages/liquid/tags/render_snippet.rb",
|
68
68
|
"lib/puffer_pages/liquid/tags/stylesheets.rb",
|
69
69
|
"lib/puffer_pages/liquid/tags/yield.rb",
|
70
70
|
"lib/puffer_pages/liquid/tracker.rb",
|
@@ -130,6 +130,7 @@ Gem::Specification.new do |s|
|
|
130
130
|
"spec/fabricators/pages_fabricator.rb",
|
131
131
|
"spec/fabricators/snippets_fabricator.rb",
|
132
132
|
"spec/integration/navigation_spec.rb",
|
133
|
+
"spec/lib/drops_spec.rb",
|
133
134
|
"spec/lib/tags_spec.rb",
|
134
135
|
"spec/models/page_spec.rb",
|
135
136
|
"spec/puffer_pages_spec.rb",
|
@@ -172,6 +173,7 @@ Gem::Specification.new do |s|
|
|
172
173
|
"spec/fabricators/pages_fabricator.rb",
|
173
174
|
"spec/fabricators/snippets_fabricator.rb",
|
174
175
|
"spec/integration/navigation_spec.rb",
|
176
|
+
"spec/lib/drops_spec.rb",
|
175
177
|
"spec/lib/tags_spec.rb",
|
176
178
|
"spec/models/page_spec.rb",
|
177
179
|
"spec/puffer_pages_spec.rb",
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Drops' do
|
4
|
+
|
5
|
+
include
|
6
|
+
|
7
|
+
def render_page(page, one_more = nil)
|
8
|
+
request = ActionController::TestRequest.new
|
9
|
+
request.env["rack.url_scheme"] = "http"
|
10
|
+
request.host = 'test.com'
|
11
|
+
request.port = 80
|
12
|
+
request.path = "/#{page.location}"
|
13
|
+
page.render 'self' => PufferPages::Liquid::PageDrop.new(page, request),
|
14
|
+
'page' => (PufferPages::Liquid::PageDrop.new(one_more, request) if one_more)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'page drop' do
|
18
|
+
|
19
|
+
before :each do
|
20
|
+
@root = Fabricate :page, :layout_name => 'foo_layout'
|
21
|
+
@foo = Fabricate :page, :slug => 'hello', :parent => @root
|
22
|
+
@bar = Fabricate :page, :slug => 'world', :parent => @foo
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should render proper url and path' do
|
26
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{{ self.path }} {{ self.url }}"
|
27
|
+
|
28
|
+
render_page(@bar).should == '/hello/world http://test.com/hello/world'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should render proper current?' do
|
32
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{{ page.current? }}"
|
33
|
+
|
34
|
+
render_page(@foo, @foo).should == 'true'
|
35
|
+
render_page(@foo, @root).should == 'false'
|
36
|
+
render_page(@foo, @bar).should == 'false'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should render proper ancestor?' do
|
40
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{{ page.ancestor? }}"
|
41
|
+
|
42
|
+
render_page(@foo, @foo).should == 'true'
|
43
|
+
render_page(@foo, @root).should == 'true'
|
44
|
+
render_page(@foo, @bar).should == 'false'
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/lib/tags_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe 'Tags' do
|
|
6
6
|
page.render 'self' => PufferPages::Liquid::PageDrop.new(page)
|
7
7
|
end
|
8
8
|
|
9
|
-
describe '
|
9
|
+
describe 'include page part' do
|
10
10
|
|
11
11
|
before :each do
|
12
12
|
@page = Fabricate :page, :layout_name => 'foo_layout'
|
@@ -15,37 +15,32 @@ describe 'Tags' do
|
|
15
15
|
@page.page_parts = [@main, @sidebar]
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'should
|
19
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{%
|
18
|
+
it 'should include page_part with string param' do
|
19
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include 'body' %}"
|
20
20
|
render_page(@page).should == @main.body
|
21
21
|
end
|
22
22
|
|
23
|
-
it 'should
|
24
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{%
|
25
|
-
render_page(@page).should == @sidebar.body
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should render yield with variable param' do
|
29
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sb = 'sidebar' %}{% yield sb %}"
|
23
|
+
it 'should include page_part with variable param' do
|
24
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sb = 'sidebar' %}{% include sb %}"
|
30
25
|
render_page(@page).should == @sidebar.body
|
31
26
|
end
|
32
27
|
|
33
28
|
end
|
34
29
|
|
35
|
-
describe '
|
30
|
+
describe 'include snippet' do
|
36
31
|
|
37
32
|
before :each do
|
38
33
|
@page = Fabricate :page, :layout_name => 'foo_layout'
|
39
34
|
@snippet = Fabricate :snippet, :name => 'snip', :body => 'snippet body'
|
40
35
|
end
|
41
36
|
|
42
|
-
it 'should
|
43
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{%
|
37
|
+
it 'should include snippet with string param' do
|
38
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include 'snippets/snip' %}"
|
44
39
|
render_page(@page).should == @snippet.body
|
45
40
|
end
|
46
41
|
|
47
|
-
it 'should
|
48
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sn = 'snip' %}{%
|
42
|
+
it 'should include snippet with variable param' do
|
43
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% assign sn = 'snippets/snip' %}{% include sn %}"
|
49
44
|
render_page(@page).should == @snippet.body
|
50
45
|
end
|
51
46
|
|
data/spec/models/page_spec.rb
CHANGED
@@ -122,7 +122,7 @@ describe Page do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should render layout' do
|
125
|
-
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{%
|
125
|
+
@layout = Fabricate :layout, :name => 'foo_layout', :body => "{% include 'body' %} {% include 'sidebar' %}"
|
126
126
|
result = @root.render 'self' => PufferPages::Liquid::PageDrop.new(@root)
|
127
127
|
result.should == "#{@root.title} #{@root.name}"
|
128
128
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffer_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- pyromaniac
|
@@ -277,9 +277,9 @@ files:
|
|
277
277
|
- lib/puffer_pages/engine.rb
|
278
278
|
- lib/puffer_pages/extensions/core.rb
|
279
279
|
- lib/puffer_pages/extensions/mapper.rb
|
280
|
+
- lib/puffer_pages/liquid/file_system.rb
|
280
281
|
- lib/puffer_pages/liquid/page_drop.rb
|
281
282
|
- lib/puffer_pages/liquid/tags/javascripts.rb
|
282
|
-
- lib/puffer_pages/liquid/tags/render_snippet.rb
|
283
283
|
- lib/puffer_pages/liquid/tags/stylesheets.rb
|
284
284
|
- lib/puffer_pages/liquid/tags/yield.rb
|
285
285
|
- lib/puffer_pages/liquid/tracker.rb
|
@@ -345,6 +345,7 @@ files:
|
|
345
345
|
- spec/fabricators/pages_fabricator.rb
|
346
346
|
- spec/fabricators/snippets_fabricator.rb
|
347
347
|
- spec/integration/navigation_spec.rb
|
348
|
+
- spec/lib/drops_spec.rb
|
348
349
|
- spec/lib/tags_spec.rb
|
349
350
|
- spec/models/page_spec.rb
|
350
351
|
- spec/puffer_pages_spec.rb
|
@@ -416,6 +417,7 @@ test_files:
|
|
416
417
|
- spec/fabricators/pages_fabricator.rb
|
417
418
|
- spec/fabricators/snippets_fabricator.rb
|
418
419
|
- spec/integration/navigation_spec.rb
|
420
|
+
- spec/lib/drops_spec.rb
|
419
421
|
- spec/lib/tags_spec.rb
|
420
422
|
- spec/models/page_spec.rb
|
421
423
|
- spec/puffer_pages_spec.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module PufferPages
|
2
|
-
module Liquid
|
3
|
-
module Tags
|
4
|
-
|
5
|
-
class RenderSnippet < ::Liquid::Tag
|
6
|
-
Syntax = /^(#{::Liquid::QuotedFragment})/
|
7
|
-
|
8
|
-
def initialize(tag_name, markup, tokens)
|
9
|
-
if markup =~ Syntax
|
10
|
-
@name = $1
|
11
|
-
else
|
12
|
-
raise SyntaxError.new("Syntax Error in 'render_snippet' - Valid syntax: render_snippet snipper_name")
|
13
|
-
end
|
14
|
-
|
15
|
-
super
|
16
|
-
end
|
17
|
-
|
18
|
-
def render(context)
|
19
|
-
name = context[@name]
|
20
|
-
snippet = Snippet.find_by_name(name)
|
21
|
-
if snippet
|
22
|
-
snippet.render(context)
|
23
|
-
else
|
24
|
-
raise ArgumentError.new("Argument error in 'render_snippet' - Can not find snippet named '#{name}'")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Liquid::Template.register_tag('render_snippet', PufferPages::Liquid::Tags::RenderSnippet)
|