diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b21bb09 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Run Tests", + "program": "${workspaceRoot}\\node_modules\\mocha\\bin\\_mocha", + "runtimeExecutable": null, + "cwd": "${workspaceRoot}", + "args": [ + "-R", + "spec", + "--colors", + "--no-timeouts" + ] + }, + { + "type": "node", + "request": "attach", + "name": "Attach to Process", + "port": 5858 + } + ] +} \ No newline at end of file diff --git a/bower.json b/bower.json index 7425e94..491ea65 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pug-bootstrap", - "version": "0.0.1", + "version": "0.0.5", "homepage": "https://github.com/mike-goodwin/pug-bootstrap", "authors": [ "mike.goodwin@owasp.org" diff --git a/components/navbar.pug b/components/navbar.pug index acca261..7fba406 100644 --- a/components/navbar.pug +++ b/components/navbar.pug @@ -18,11 +18,15 @@ mixin navbar(name, id, style, href) block mixin nav_item(href, active) - li(class=active): a( href=href ) - block + + if(active) + li(class="active"): a( href=href ): block + else + li: a( href=href ): block mixin nav_item_dropdown(href, active) - li(class=["dropdown", active]) + - var ddclass = active ? ["dropdown", "active"] : "dropdown" + li(class=ddclass) a.dropdown-toggle( href=href, data-toggle="dropdown", role="button", aria-expanded="false" )= attributes.label span.caret ul.dropdown-menu( role="menu" ) @@ -35,7 +39,7 @@ mixin nav_header li.dropdown-header block -mixin navbar-fixed(name,id,style) +mixin navbar-fixed(name,id,style,href) - var style = (typeof style === 'undefined') ? "default" : style nav( role="navigation", class=["navbar","navbar-fixed-top","navbar-" + style] ) .container @@ -45,12 +49,12 @@ mixin navbar-fixed(name,id,style) span.icon-bar span.icon-bar span.icon-bar - a.navbar-brand(href='#')= name + a.navbar-brand(href=href)= name .collapse.navbar-collapse( id=id ) ul.nav.navbar-nav block -mixin navbar-static(name,id,style) +mixin navbar-static(name,id,style,href) - var style = (typeof style === 'undefined') ? "default" : style nav( role="navigation", class=["navbar","navbar-static-top","navbar-" + style] ) .container @@ -60,7 +64,7 @@ mixin navbar-static(name,id,style) span.icon-bar span.icon-bar span.icon-bar - a.navbar-brand(href='#')= name + a.navbar-brand(href=href)= name .collapse.navbar-collapse( id=id ) ul.nav.navbar-nav block diff --git a/package.json b/package.json index 855edc2..f3e3414 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pug-bootstrap", - "version": "0.0.4", + "version": "0.0.5", "description": "Bootstrap framework written completely using mixins in pug", "main": "bootstrap.pug", "scripts": { diff --git a/test/fixtures/navbars/nav-divider.pug b/test/fixtures/navbars/nav-divider.pug new file mode 100644 index 0000000..ab8df69 --- /dev/null +++ b/test/fixtures/navbars/nav-divider.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++nav_divider \ No newline at end of file diff --git a/test/fixtures/navbars/nav-header.pug b/test/fixtures/navbars/nav-header.pug new file mode 100644 index 0000000..0d864f5 --- /dev/null +++ b/test/fixtures/navbars/nav-header.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++nav_header Test Header \ No newline at end of file diff --git a/test/fixtures/navbars/nav-item-dropdown.pug b/test/fixtures/navbars/nav-item-dropdown.pug new file mode 100644 index 0000000..4af1eb9 --- /dev/null +++ b/test/fixtures/navbars/nav-item-dropdown.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++nav_item_dropdown(href, active) \ No newline at end of file diff --git a/test/fixtures/navbars/navbar-fixed.pug b/test/fixtures/navbars/navbar-fixed.pug new file mode 100644 index 0000000..d3a5cbc --- /dev/null +++ b/test/fixtures/navbars/navbar-fixed.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++navbar-fixed(name, id, style, href) \ No newline at end of file diff --git a/test/fixtures/navbars/navbar-item.pug b/test/fixtures/navbars/navbar-item.pug new file mode 100644 index 0000000..0fc0166 --- /dev/null +++ b/test/fixtures/navbars/navbar-item.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++nav_item(href, active) Test \ No newline at end of file diff --git a/test/fixtures/navbars/navbar-static.pug b/test/fixtures/navbars/navbar-static.pug new file mode 100644 index 0000000..636953b --- /dev/null +++ b/test/fixtures/navbars/navbar-static.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++navbar-static(name, id, style, href) \ No newline at end of file diff --git a/test/fixtures/navbars/navbar.pug b/test/fixtures/navbars/navbar.pug new file mode 100644 index 0000000..75067c9 --- /dev/null +++ b/test/fixtures/navbars/navbar.pug @@ -0,0 +1,2 @@ +include ../../../components/navbar.pug ++navbar(name, id, style, href) \ No newline at end of file diff --git a/test/navbars.js b/test/navbars.js new file mode 100644 index 0000000..cc3078a --- /dev/null +++ b/test/navbars.js @@ -0,0 +1,77 @@ +var assert = require("assert"); +var jade = require("pug"); +var fs = require("fs"); +var path = require("path"); + +describe("Navbars", function () { + it('should generate a navbar', function () { + var locals = { + name: 'navbar-name', + id: 'navbar-id', + style: 'style', + href: 'href' + }; + var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar.pug")); + assert.equal('', fn(locals)); + }); + it('should generate a static navbar', function () { + var locals = { + name: 'navbar-name', + id: 'navbar-id', + style: 'style', + href: 'href' + }; + var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-static.pug")); + assert.equal('', fn(locals)); + }); + it('should generate a fixed navbar', function () { + var locals = { + name: 'navbar-name', + id: 'navbar-id', + style: 'style', + href: 'href' + }; + var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-fixed.pug")); + assert.equal('', fn(locals)); + }); + it('should generate a navbar item', function () { + var locals = { + href: 'href' + }; + var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-item.pug")); + assert.equal('