mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-19 02:44:29 -05:00
Support a new relative_include tag
This commit is contained in:
25
test/source/_posts/2014-09-02-relative-includes.markdown
Normal file
25
test/source/_posts/2014-09-02-relative-includes.markdown
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: Post
|
||||
layout: post
|
||||
include1: rel_include.html
|
||||
include2: relative_includes/rel_include
|
||||
include3: rel_INCLUDE
|
||||
include4: params
|
||||
include5: clude
|
||||
---
|
||||
|
||||
Liquid tests
|
||||
- 1 {% relative_include relative_includes/{{ page.include1 }} %}
|
||||
- 2 {% relative_include {{ page.include2 | append: '.html' }} %}
|
||||
- 3 {% relative_include relative_includes/{{ page.include3 | downcase | append: '.html' }} %}
|
||||
|
||||
Whitespace tests
|
||||
- 4 {% relative_include relative_includes/{{page.include1}} %}
|
||||
- 5 {% relative_include relative_includes/{{ page.include1}} %}
|
||||
- 6 {% relative_include relative_includes/{{ page.include3 | downcase | append: '.html'}} %}
|
||||
|
||||
Parameters test
|
||||
- 7 {% relative_include relative_includes/{{ page.include4 | append: '.html' }} var1='foo' var2='bar' %}
|
||||
|
||||
Partial variable test
|
||||
- 8 {% relative_include relative_includes/rel_in{{ page.include5 }}.html %}
|
||||
7
test/source/_posts/relative_includes/params.html
Normal file
7
test/source/_posts/relative_includes/params.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<span id='include-param'>{{include.param}}</span>
|
||||
|
||||
<ul id='param-list'>
|
||||
{% for param in include %}
|
||||
<li>{{param[0]}} = {{param[1]}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
1
test/source/_posts/relative_includes/rel_include.html
Normal file
1
test/source/_posts/relative_includes/rel_include.html
Normal file
@@ -0,0 +1 @@
|
||||
relative_included
|
||||
@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
should "ensure post count is as expected" do
|
||||
assert_equal 42, @site.posts.size
|
||||
assert_equal 43, @site.posts.size
|
||||
end
|
||||
|
||||
should "insert site.posts into the index" do
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestSite < Test::Unit::TestCase
|
||||
Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
|
||||
end
|
||||
@site = Site.new(Jekyll.configuration)
|
||||
@num_invalid_posts = 2
|
||||
@num_invalid_posts = 4
|
||||
end
|
||||
|
||||
should "have an empty tag hash by default" do
|
||||
|
||||
@@ -509,5 +509,40 @@ CONTENT
|
||||
assert_match %r{8 included}, @content
|
||||
end
|
||||
end
|
||||
|
||||
context "relative include tag with variable and liquid filters" do
|
||||
setup do
|
||||
stub(Jekyll).configuration do
|
||||
site_configuration({'pygments' => true})
|
||||
end
|
||||
|
||||
site = Site.new(Jekyll.configuration)
|
||||
post = Post.new(site, source_dir, '', "2014-09-02-relative-includes.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 relative_include}, @content
|
||||
assert_match %r{2 relative_include}, @content
|
||||
assert_match %r{3 relative_include}, @content
|
||||
end
|
||||
|
||||
should "include file as variable and liquid filters with arbitrary whitespace" do
|
||||
assert_match %r{4 relative_include}, @content
|
||||
assert_match %r{5 relative_include}, @content
|
||||
assert_match %r{6 relative_include}, @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
|
||||
|
||||
should "include file as partial variable" do
|
||||
assert_match %r{8 relative_include}, @content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user