﻿@{
    // odd formatting in this file is to cause more attractive results in the output.
    var items = Enumerable.Cast<dynamic>((System.Collections.IEnumerable)Model);
}
@{
    if (!HasText(Model.Text))
    {
        @DisplayChildren(Model)
    }
    else
    {
        if ((bool)Model.Selected)
        {
            Model.Classes.Add("current");
            Model.Classes.Add("active"); // for bootstrap
        }

        if (items.Any())
        {
            Model.Classes.Add("dropdown");
            // for bootstrap and/or font-awesome            
            Model.BootstrapAttributes = "data-toggle='dropdown'";
            Model.BootstrapIcon = "<span class='glyphicon glyphicon-hand-down'></span>";
        }

        @* morphing the shape to keep Model untouched*@
        Model.Metadata.Alternates.Clear();
        Model.Metadata.Type = "MenuItemLink";

        @* render the menu item only if it has some content *@
        var renderedMenuItemLink = Display(Model);
        if (HasText(renderedMenuItemLink))
        {
            var tag = Tag(Model, "li");
            @tag.StartElement
            @renderedMenuItemLink

            if (items.Any())
            {
                <ul class="dropdown-menu">
                    @DisplayChildren(Model)
                </ul>
            }

            @tag.EndElement
        }
    }
}
﻿@{
    // odd formatting in this file is to cause more attractive results in the output.
    var items = Enumerable.Cast<dynamic>((System.Collections.IEnumerable)Model);
}
@{
    if (!HasText(Model.Text))
    {
        @DisplayChildren(Model)
    }
    else
    {
        if ((bool)Model.Selected)
        {
            Model.Classes.Add("current");
            Model.Classes.Add("active"); // for bootstrap
        }

        if (items.Any())
        {
            Model.Classes.Add("dropdown");
            // for bootstrap and/or font-awesome            
            Model.BootstrapAttributes = "data-toggle='dropdown'";
            Model.BootstrapIcon = "<span class='glyphicon glyphicon-chevron-down'></span>";
        }

        @* morphing the shape to keep Model untouched*@
        Model.Metadata.Alternates.Clear();
        Model.Metadata.Type = "MenuItemLink";

        @* render the menu item only if it has some content *@
        var renderedMenuItemLink = Display(Model);
        if (HasText(renderedMenuItemLink))
        {
            var tag = Tag(Model, "li");
            @tag.StartElement
            @renderedMenuItemLink

            if (items.Any())
            {
                <ul class="dropdown-menu">
                    @DisplayChildren(Model)
                </ul>
            }

            @tag.EndElement
        }
    }
}
Use chevron down for drop downs.
Use chevron down for drop downs.
