Helper Addition

Jan 5, 2014 at 2:13 PM
Hi,

This stuff is great, but I was trying to use it with TwitterBootstrpMVC5 (BMVC) and couldnt get the icons to show when using prepend or append. Mostly because the input for the BMVC is only the CSS for the icon, it handles the wrapping of the code in the <i>. So my solution was to add another extension method for CssOnly output.

Here is the code:
public static string CssOnly(this FontAwesomeIcon helper)
        {
            var css = helper.ClassAttributes.Values.Aggregate("",(o,i)=>o + " " + i).TrimStart();
            return css;
        }
This allows you to use the BMVC code and font awesome fonts easily, for example:
@Html.Bootstrap().SubmitButton().Text("Log in").Style(ButtonStyle.Primary).PrependIcon(FontAwesomeIconSet.Check.CssOnly())
Maybe you could add this to the builtin extension methods.

Thanks,
Jason
Coordinator
Jan 5, 2014 at 4:41 PM
Edited Jan 6, 2014 at 9:54 AM
Jason,

Thank you. I will add this to the next release. I have a new version almost ready where I have refactored the base classes and interfaces into a separate library for other projects using this same approach (currently working on a similar library for Morris charts). I'm letting you know this because I have changed the namespace slightly => Mvc.RazorTools.FontAwesome (note the NuGet id will not change). This addition will be added to 4.0.3.9.

Dan
Coordinator
Jan 5, 2014 at 10:15 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.