Commit 723f4f75 authored by Sylvester Keil's avatar Sylvester Keil

add interpolation support to query parameter

parent 2e59679f
......@@ -151,6 +151,41 @@ Feature: BibTeX
And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
@tags @filter @variables @wip
Scenario: Filter using interpolated query variable
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
},
@book{smalltalk,
title = {Smalltalk Best Practice Patterns},
author = {Kent Beck},
year = {1996},
publisher = {Prentice Hall}
}
"""
And I have a page "scholar.html":
"""
---
---
{% assign yr = 2000 %}
{% bibliography -f references --query @book[year <= {{ yr }}] %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/scholar.html" file should exist
And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
@tags @bibliography @prefix
Scenario: A Prefixed Bibliography
Given I have a scholar configuration with:
......
......@@ -14,8 +14,7 @@ module Jekyll
# #site readers
module Utilities
attr_reader :config, :site, :query,
:context, :prefix, :text, :max
attr_reader :config, :site, :context, :prefix, :text, :max
def split_arguments(arguments)
......@@ -123,6 +122,10 @@ module Jekyll
@bibliography
end
def query
interpolate @query
end
def entries
sort bibliography[query || config['query']]
end
......@@ -387,6 +390,14 @@ module Jekyll
end
end
def interpolate(string)
return unless string
string.gsub(/{{\s*([\w\.]+)\s*}}/) do |match|
context.send(:resolve, $1) || match
end
end
def set_context_to(context)
@context, @site, = context, context.registers[:site]
config.merge!(site.config['scholar'] || {})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment