Skip to content

Commit

Permalink
Merge 0e0f31f into 00c53e4
Browse files Browse the repository at this point in the history
  • Loading branch information
rseac committed Jan 10, 2018
2 parents 00c53e4 + 0e0f31f commit 1a72a86
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
83 changes: 83 additions & 0 deletions features/interpolate.feature
@@ -0,0 +1,83 @@
Feature: Interpolations ...
As a scholar who likes to blog
I want to reference cool papers and books from my bibliography

@tags @reference @liquid @interpolate
Scenario: Interpolate liquid variables
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| bibliography | my_references |
And I have a "_bibliography" directory
And I have a file "_bibliography/my_references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a file "custom.csl":
"""
<style>
<citation>
<layout>
<text variable="title"/>
</layout>
</citation>
<bibliography>
<layout>
<text variable="title"/>
</layout>
</bibliography>
</style>
"""
And I have a page "scholar.html":
"""
---
---
{% assign style_file = 'custom.csl' %}
{% bibliography --style {{style_file}} %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should see "The Ruby Programming Language" in "_site/scholar.html"


@tags @grouping
Scenario: Local grouping override - grouping by year with interpolation
Given I have a scholar configuration with:
| key | value |
| group_by | none |
| group_order | ascending |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@book{ruby1,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
@book{ruby2,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2007},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html":
"""
---
---
{% assign group_year = 'year' %}
{% bibliography -f references --group_by {{group_year}} --group_order descending %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
Then I should see "<h2 class=\"bibliography\">2007</h2>" in "_site/scholar.html"
And I should see "<h2 class=\"bibliography\">2008</h2>" in "_site/scholar.html"
And "2008" should come before "2007" in "_site/scholar.html"
4 changes: 2 additions & 2 deletions lib/jekyll/scholar/utilities.rb
Expand Up @@ -222,7 +222,7 @@ def sort_order
end

def group_by
@group_by ||= config['group_by']
@group_by = interpolate(@group_by) || config['group_by']
end

def group?
Expand Down Expand Up @@ -436,7 +436,7 @@ def reference_tag(entry, index = nil)
end

def style
@style || config['style']
interpolate(@style)|| config['style']
end

def missing_reference
Expand Down

0 comments on commit 1a72a86

Please sign in to comment.