I have a view that displays a list of comments. Now a comment can have a document associated to it so as I am displaying each comment I need to check whether or not “AttachedDocumentID” has a value and if so display a HTML.ActionLink to it.
Not sure on the best way to do this to avoid having an if statement in the view (which I’m led to believe is bad form) and I didn’t really want to have any html code generated in the helper.
What other options do I have?
Personally I’d do it as an if statement in the view as it’s clear what you’re intending, but you could add an extension method if you wanted:
Then call it in your view like normal