<commit_before>﻿using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.ContentManagement.ViewModels;

namespace Orchard.Mvc.Html {
    public static class TemplateViewModelExtensions {
        public static void RenderTemplates(this HtmlHelper html, IEnumerable<TemplateViewModel> templates) {
            if (templates == null)
                return;

            foreach (var template in templates) {
                html.RenderTemplates(template);
            }
        }

        public static void RenderTemplates(this HtmlHelper html, TemplateViewModel template) {
            if (template.WasUsed)
                return;

            template.WasUsed = true;

            var templateInfo = html.ViewContext.ViewData.TemplateInfo;<commit_msg>Adding template sorting by optional position parameter<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.ContentManagement.ViewModels;
using Orchard.UI.Navigation;

namespace Orchard.Mvc.Html {
    public static class TemplateViewModelExtensions {
        public static void RenderTemplates(this HtmlHelper html, IEnumerable<TemplateViewModel> templates) {
            if (templates == null)
                return;

            foreach (var template in templates.OrderByDescending(t => t.Position, new PositionComparer())) {
                html.RenderTemplates(template);
            }
        }

        public static void RenderTemplates(this HtmlHelper html, TemplateViewModel template) {
            if (template.WasUsed)
                return;

            template.WasUsed = true;

            var templateInfo = html.ViewContext.ViewData.TemplateInfo;
{'fraction_non_alphanumeric': 0.07381776239907728, 'fraction_numerical': 0.0, 'mean_word_length': 2.660337552742616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '366841', 'n_tokens_mistral': 435, 'n_tokens_neox': 417, 'n_words': 108}