From 7cec996f90cd31ca2572e444717bfcc4ddee52fc Mon Sep 17 00:00:00 2001 From: Anatol Broder Date: Tue, 17 Sep 2013 21:41:11 +0200 Subject: [PATCH] Validate the entire markup as soon as possible --- lib/jekyll/tags/include.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index c4dea149..f02f6310 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -2,21 +2,24 @@ module Jekyll module Tags class IncludeTag < Liquid::Tag - VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/ - SYNTAX_EXAMPLE = "{% include file.ext param='value' param2='value' %}" + VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/ + INCLUDES_DIR = '_includes' def initialize(tag_name, markup, tokens) super @file, @params = markup.strip.split(' ', 2); + validate_syntax + end + + def validate_syntax validate_file_name + validate_params if @params end def parse_params(context) - validate_params - params = {} markup = @params