Skip to content

Instantly share code, notes, and snippets.

@ryankelley
Created March 25, 2010 13:32
Show Gist options
  • Save ryankelley/343554 to your computer and use it in GitHub Desktop.
Save ryankelley/343554 to your computer and use it in GitHub Desktop.
public class OddEvenLiModifier : IPartialElementModifier
{
private readonly Func<AccessorDef, bool> _matches;
private readonly Func<AccessorDef, EachPartialTagModifier> _modifierBuilder;
private bool matches(AccessorDef accessorDef)
{
return accessorDef.ModelType.IsType<ProjectListModel>();
}
private EachPartialTagModifier modifier = (request, tag, index, count) =>
{
if ((index%2) == 0)
tag.AddClass("odd");
else
tag.AddClass("even");
if (index == 0)
tag.AddClass("first");
if (index == count - 1)
tag.AddClass("last");
};
public EachPartialTagModifier CreateModifier(AccessorDef accessorDef)
{
var something = matches(accessorDef) ? modifier : null;
return something;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment