Merge pull request #86 from mariovisic/hotfix/nested_snippets
Fix for issue #84 (Nested snippets)
This commit is contained in:
commit
43670714b9
39
features/admin/snippets.feature
Normal file
39
features/admin/snippets.feature
Normal file
@ -0,0 +1,39 @@
|
||||
Feature: Snippets
|
||||
In order to manage snippets
|
||||
As an administrator
|
||||
I want to add/edit/delete snippets of my site
|
||||
|
||||
Background:
|
||||
Given I have the site: "test site" set up
|
||||
And I am an authenticated user
|
||||
And a page named "home" with the template:
|
||||
"""
|
||||
{% include 'yield' %}
|
||||
"""
|
||||
And a snippet named "yield" with the template:
|
||||
"""
|
||||
"yield"
|
||||
"""
|
||||
|
||||
|
||||
Scenario: Creating a Snippet
|
||||
When I go to theme assets
|
||||
And I follow "new snippet"
|
||||
And I fill in "Name" with "Banner"
|
||||
And I fill in "Slug" with "banner"
|
||||
And I fill in "snippet_template" with "banner"
|
||||
And I press "Create"
|
||||
Then I should see "Snippet was successfully created."
|
||||
And I should have "banner" in the banner snippet
|
||||
|
||||
Scenario: Updating a Snippet that includes another snippet
|
||||
Given a snippet named "other" with the template:
|
||||
"""
|
||||
"other"
|
||||
"""
|
||||
When I go to theme assets
|
||||
And I follow "yield"
|
||||
And I fill in "snippet_template" with "{% include 'other' %}"
|
||||
And I press "Update"
|
||||
Then I should see "Snippet was successfully updated."
|
||||
And I should have "{% include 'other' %}" in the yield snippet
|
@ -13,4 +13,11 @@ Given /^a snippet named "([^"]*)" with the template:$/ do |name, template|
|
||||
@snippet = create_snippet(name, template)
|
||||
end
|
||||
|
||||
# checks to see if a string is in the slug
|
||||
Then /^I should have "(.*)" in the (.*) snippet/ do |content, snippet_slug|
|
||||
snippet = @site.snippets.where(:slug => snippet_slug).first
|
||||
raise "Could not find snippet: #{snippet_slug}" unless snippet
|
||||
|
||||
snippet.template.should == content
|
||||
end
|
||||
|
||||
|
@ -12,12 +12,17 @@ module Locomotive
|
||||
|
||||
@slug = @template_name.gsub('\'', '')
|
||||
|
||||
if @context[:snippets].present?
|
||||
(@context[:snippets] << @slug).uniq!
|
||||
else
|
||||
@context[:snippets] = [@slug]
|
||||
end
|
||||
|
||||
if @context[:site].present?
|
||||
snippet = @context[:site].snippets.where(:slug => @slug).first
|
||||
|
||||
self.refresh(snippet) if snippet
|
||||
end
|
||||
end
|
||||
|
||||
def render(context)
|
||||
return '' if @partial.nil?
|
||||
|
Loading…
Reference in New Issue
Block a user