ref: 03d1a57fea650c13f7ca05481f5c84ffabeb2757
parent: 5e14af957a5167770e8498df6ea356326aae3b0b
author: Noah Campbell <[email protected]>
date: Tue Oct 1 08:51:00 EDT 2013
Set the name of the Nav attribute to select
--- a/transform/nav.go
+++ b/transform/nav.go
@@ -8,6 +8,7 @@
type NavActive struct {
Section string
+ AttrName string
}
func (n *NavActive) Apply(r io.Reader, w io.Writer) (err error) {
@@ -22,7 +23,11 @@
return
}
- tr.Apply(htmltran.ModifyAttrib("class", "active"), fmt.Sprintf("li[data-nav=%s]", n.Section))
+ if n.AttrName == "" {
+ n.AttrName = "hugo-nav"
+ }
+
+ tr.Apply(htmltran.ModifyAttrib("class", "active"), fmt.Sprintf("li[%s=%s]", n.AttrName, n.Section))
return tr.Render(w)
}
--- a/transform/nav_test.go
+++ b/transform/nav_test.go
@@ -12,8 +12,8 @@
<body>
<nav>
<ul class="nav navbar-nav">
- <li data-nav="section_1"><a href="#">Section 1</a></li>
- <li data-nav="section_2"><a href="#">Section 2</a></li>
+ <li hugo-nav="section_1"><a href="#">Section 1</a></li>
+ <li hugo-nav="section_2"><a href="#">Section 2</a></li>
</ul>
</nav>
</body>
@@ -23,8 +23,8 @@
<body>
<nav>
<ul class="nav navbar-nav">
- <li data-nav="section_1"><a href="#">Section 1</a></li>
- <li data-nav="section_2" class="active"><a href="#">Section 2</a></li>
+ <li hugo-nav="section_1"><a href="#">Section 1</a></li>
+ <li hugo-nav="section_2" class="active"><a href="#">Section 2</a></li>
</ul>
</nav>