Fix minor code style recommendations and typos.
This commit is contained in:
parent
66c4ff8800
commit
1ef7653fed
|
@ -235,13 +235,13 @@ module Jekyll
|
|||
# Returns the filtered array of objects
|
||||
def where_exp(input, variable, expression)
|
||||
return input unless input.is_a?(Enumerable)
|
||||
input = input.values if input.is_a?(Hash)
|
||||
input = input.values if input.is_a?(Hash) # FIXME
|
||||
|
||||
c = parse_condition(expression)
|
||||
condition = parse_condition(expression)
|
||||
@context.stack do
|
||||
input.select do |object|
|
||||
@context[variable] = object
|
||||
c.evaluate(@context)
|
||||
condition.evaluate(@context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -388,13 +388,13 @@ module Jekyll
|
|||
# Parse a string to a Liquid Condition
|
||||
def parse_condition(exp)
|
||||
parser = Liquid::Parser.new(exp)
|
||||
a = parser.expression
|
||||
if op = parser.consume?(:comparison)
|
||||
b = parser.expression
|
||||
condition = Liquid::Condition.new(a, op, b)
|
||||
else
|
||||
condition = Liquid::Condition.new(a)
|
||||
end
|
||||
left_expr = parser.expression
|
||||
condition =
|
||||
if operator = parser.consume?(:comparison)
|
||||
Liquid::Condition.new(left_expr, operator, parser.expression)
|
||||
else
|
||||
Liquid::Condition.new(left_expr)
|
||||
end
|
||||
parser.consume(:end_of_string)
|
||||
|
||||
condition
|
||||
|
|
|
@ -100,7 +100,7 @@ common tasks easier.
|
|||
<code class="filter">{% raw %}{{ site.members | where_exp:"item",
|
||||
"item.graduation_year < 2014" }}{% endraw %}</code>
|
||||
<code class="filter">{% raw %}{{ site.members | where_exp:"item",
|
||||
"item.projects includes 'foo'" }}{% endraw %}</code>
|
||||
"item.projects contains 'foo'" }}{% endraw %}</code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue