added logic for multiple links handling

uses liquid templates for loop variables to determing where in the loop we are.