public void Include(string templateName) { if (_includeLevel >= IncludeLimit) { throw new NustacheException( string.Format("You have reached the include limit of {0}. Are you trying to render infinitely recursive templates or data?", IncludeLimit)); } _includeLevel++; TemplateDefinition templateDefinition = GetTemplateDefinition(templateName); if (templateDefinition != null) { templateDefinition.Render(this); } else if (_templateLocator != null) { var template = _templateLocator(templateName); if (template != null) { template.Render(this); } } _includeLevel--; }
public void Include(string templateName, string indent) { if (_includeLevel >= IncludeLimit) { throw new NustacheException( string.Format("You have reached the include limit of {0}. Are you trying to render infinitely recursive templates or data?", IncludeLimit)); } _includeLevel++; var oldIndent = _indent; _indent = (_indent ?? "") + (indent ?? ""); TemplateDefinition templateDefinition = GetTemplateDefinition(templateName); if (templateDefinition != null) { templateDefinition.Render(this); } else if (_templateLocator != null) { var template = _templateLocator(templateName); if (template != null) { // push the included template on the stack so that internally defined templates can be resolved properly later. // designed to pass test Describe_Template_Render.It_can_include_templates_over_three_levels_with_external_includes() this.Enter(template); template.Render(this); this.Exit(); } } _indent = oldIndent; _includeLevel--; }