From 684b1ddf5cd27ccb5840ef0e4cc07a9f0f289465 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Thu, 2 Jun 2011 21:56:05 +0800 Subject: [PATCH] Nested snippets now update correctly, fixes #84 --- lib/locomotive/liquid/tags/snippet.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/locomotive/liquid/tags/snippet.rb b/lib/locomotive/liquid/tags/snippet.rb index 336905bf..704a6017 100644 --- a/lib/locomotive/liquid/tags/snippet.rb +++ b/lib/locomotive/liquid/tags/snippet.rb @@ -12,11 +12,14 @@ module Locomotive @slug = @template_name.gsub('\'', '') + @context[:snippets] = [] if @context[:snippets].nil? (@context[:snippets] << @slug).uniq! - snippet = @context[:site].snippets.where(:slug => @slug).first + if @context[:site].present? + snippet = @context[:site].snippets.where(:slug => @slug).first - self.refresh(snippet) if snippet + self.refresh(snippet) if snippet + end end def render(context)