From 657a8d7239533553571559aad954b40764e55b79 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 25 Nov 2015 16:37:08 +0800 Subject: [PATCH] Allow users to input multiple variables in include tag --- features/include_tag.feature | 8 ++++++++ lib/jekyll/tags/include.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/features/include_tag.feature b/features/include_tag.feature index cab01187..83ae379f 100644 --- a/features/include_tag.feature +++ b/features/include_tag.feature @@ -89,3 +89,11 @@ Feature: Include tags Then I have an "_includes/one.html" file that contains "include content changed" When I run jekyll build Then I should see "include content changed" in "_site/index.html" + + Scenario: Include a file with multiple variables + Given I have an _includes directory + And I have an "_includes/header-en.html" file that contains "include" + And I have an "index.html" page that contains "{% assign name = 'header' %}{% assign locale = 'en' %}{% include {{name}}-{{locale}}.html %}" + When I run jekyll build + Then the _site directory should exist + And I should see "include" in "_site/index.html" diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 0e944407..2e39738e 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -16,7 +16,7 @@ module Jekyll attr_reader :includes_dir VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/ - VARIABLE_SYNTAX = /(?[^{]*\{\{\s*(?[\w\-\.]+)\s*(\|.*)?\}\}[^\s}]*)(?.*)/ + VARIABLE_SYNTAX = /(?[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)(?.*)/ def initialize(tag_name, markup, tokens) super