From 1291b68aba733ec0bf7083302aac7b2bfc05d30c Mon Sep 17 00:00:00 2001 From: dinedine Date: Sat, 8 Jan 2011 00:10:44 +0100 Subject: [PATCH] in special sitation inherited templates were not correctly updated --- doc/TODO | 2 +- lib/locomotive/liquid/tags/extends.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/TODO b/doc/TODO index 795b0ad4..4aaadb88 100644 --- a/doc/TODO +++ b/doc/TODO @@ -12,6 +12,7 @@ x nav tag: x site | page | parent x retrieve only important page information from mongodb x published by default when importing pages +x page redirection BACKLOG: @@ -42,7 +43,6 @@ NICE TO HAVE: - traffic statistics - asset picker (content instance) - page with regexp url ? -- page redirection (option) - automatic update ! - page not found (front) => if logged in, link to create the page - switch to list (theme assets / assets ?). delete all in once (with checkbox) or see details (updated_at, size, ...etc) diff --git a/lib/locomotive/liquid/tags/extends.rb b/lib/locomotive/liquid/tags/extends.rb index 71618910..64420593 100644 --- a/lib/locomotive/liquid/tags/extends.rb +++ b/lib/locomotive/liquid/tags/extends.rb @@ -19,7 +19,9 @@ module Locomotive def parse_parent_template if @template_name == 'parent' if @context[:cached_parent] - @context[:parent_page] = @context[:cached_parent] + @context[:parent_page] = @context[:cached_parent] #.clone # parent must not be modified + + @context[:cached_parent].instance_variable_set(:@template, nil) # force to reload the template @context[:cached_parent] = nil else @context[:parent_page] = @context[:page].parent @@ -31,7 +33,12 @@ module Locomotive raise PageNotFound.new("Page with fullpath '#{@template_name}' was not found") if @context[:parent_page].nil? - @context[:parent_page].template + # be sure to work with a copy of the parent template otherwise there will be conflicts + parent_template = @context[:parent_page].template.clone + + @context[:parent_page].instance_variable_set(:@template, parent_template) + + parent_template end end