public bool HasVariable(string name)
 {
     if (name == _key)
     {
         return(true);
     }
     return(_parentScope != null && _parentScope.HasVariable(name));
 }
        public string PreprocessIncludeRegions(string template)
        {
            //normalize line endings
            template = template.Split("\r").Join("\n").Split("\n\n").Join("\n");

            var lines  = template.Split("\n");
            var source = "";
            var level  = 0;

            foreach (var l in lines)
            {
                if (l.IndexOf(StartRegion, StringComparison.Ordinal) > -1)
                {
                    var name = l.Substring(StartRegion.Length);
                    if (!_variableResolver.HasVariable(name))
                    {
                        level++;
                    }
                }
                else if (l.IndexOf(EndRegion, StringComparison.Ordinal) > -1)
                {
                    if (level > 0)
                    {
                        level--;
                    }
                }
                else
                {
                    if (level > 0)
                    {
                        continue;
                    }
                    source += l + "\n";
                }
            }
            return(source);
        }