-
-
Save danrichman/5837cc79a73f8e5f03dc to your computer and use it in GitHub Desktop.
Navigation bar component in Marko JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- /src/pages/homepage/homepage.marko --> | |
<layout-use template="../../layouts/layout.marko" navbar-current="home"> | |
<layout-put into="body"> | |
... | |
</layout-put> | |
</layout-use> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- /src/layouts/layout.marko --> | |
<html> | |
<head> | |
</head> | |
<body> | |
<app-navbar current="${data.navbarCurrent}" /> | |
<layout-placeholder name="body" /> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<def function="navLink(name, title, href)"> | |
<a href="${href}" class="{?data.current === name;current}"> | |
${title} | |
</a> | |
</def> | |
<!-- /src/components/app-navbar/template.marko --> | |
<div id="navbar"> | |
<p> | |
<invoke function="navLink" name="home" title="Home" href="/" /> | | |
<invoke function="navLink" name="about" title="About" href="/about" /> | | |
<invoke function="navLink" name="users" title="Users" href="/users" /> | | |
<invoke function="navLink" name="blog" title="Blog" href="/blog" /> | | |
<invoke function="navLink" name="contact" title="Contact" href="/contact" /> | | |
</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://gitter.im/marko-js/marko?at=5658c98728c5280777268674