mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
variables in include tag with filters
This commit is contained in:
1
test/source/_includes/include.html
Normal file
1
test/source/_includes/include.html
Normal file
@@ -0,0 +1 @@
|
||||
included
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: Post
|
||||
layout: post
|
||||
include1: include.html
|
||||
include2: include
|
||||
include3: INCLUDE
|
||||
include4: params
|
||||
---
|
||||
|
||||
Liquid tests
|
||||
- 1 {% include {{ page.include1 }} %}
|
||||
- 2 {% include {{ page.include2 | append: '.html' }} %}
|
||||
- 3 {% include {{ page.include3 | downcase | append: '.html' }} %}
|
||||
- 4 {% include {{ page.include2 | append: '.html' }} %}
|
||||
|
||||
Whitespace tests
|
||||
- 5 {% include {{page.include1}} %}
|
||||
- 6 {% include {{ page.include1}} %}
|
||||
- 7 {% include {{ page.include3 | downcase | append: '.html'}} %}
|
||||
|
||||
Parameters test
|
||||
- 8 {% include {{ page.include4 | append: '.html' }} var1='foo' var2='bar' %}
|
||||
@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "ensure post count is as expected" do
|
||||
assert_equal 36, @site.posts.size
|
||||
assert_equal 37, @site.posts.size
|
||||
end
|
||||
|
||||
should "insert site.posts into the index" do
|
||||
|
||||
@@ -471,5 +471,36 @@ CONTENT
|
||||
end
|
||||
end
|
||||
|
||||
context "include tag with variable and liquid filters" do
|
||||
setup do
|
||||
stub(Jekyll).configuration do
|
||||
Jekyll::Configuration::DEFAULTS.deep_merge({'pygments' => true}).deep_merge({'source' => source_dir, 'destination' => dest_dir})
|
||||
end
|
||||
|
||||
site = Site.new(Jekyll.configuration)
|
||||
post = Post.new(site, source_dir, '', "2013-12-17-include-variable-filters.markdown")
|
||||
layouts = { "default" => Layout.new(site, source_dir('_layouts'), "simple.html")}
|
||||
post.render(layouts, {"site" => {"posts" => []}})
|
||||
@content = post.content
|
||||
end
|
||||
|
||||
should "include file as variable with liquid filters" do
|
||||
assert_match %r{1 included}, @content
|
||||
assert_match %r{2 included}, @content
|
||||
assert_match %r{3 included}, @content
|
||||
assert_match %r{4 included}, @content
|
||||
end
|
||||
|
||||
should "include file as variable and liquid filters with arbitrary whitespace" do
|
||||
assert_match %r{5 included}, @content
|
||||
assert_match %r{6 included}, @content
|
||||
assert_match %r{7 included}, @content
|
||||
end
|
||||
|
||||
should "include file as variable and filters with additional parameters" do
|
||||
assert_match '<li>var1 = foo</li>', @content
|
||||
assert_match '<li>var2 = bar</li>', @content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user