Skip to content

Instantly share code, notes, and snippets.

@wenbing
Created May 18, 2013 01:02
Show Gist options
  • Save wenbing/5602822 to your computer and use it in GitHub Desktop.
Save wenbing/5602822 to your computer and use it in GitHub Desktop.
<#function bodyClass>
<#local
uri = page.request.getRequestURI(),
uri = uri?replace("/", "", "f"),
parts = uri?split("/"),
classes = "page"
/>
<#if uri == "/">
<#local classes = classes + " page-index" />
</#if>
<#list parts as part>
<#local substr = "" />
<#list parts[0..part_index] as str>
<#local substr = substr + "-" + str />
</#list>
<#local classes = classes + " page" + substr />
</#list>
<#return classes>
</#function>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment