Function to render HTML from template and data