Skip to content

Instantly share code, notes, and snippets.

@mikaelbr
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelbr/a13b8efe37d24ef27600 to your computer and use it in GitHub Desktop.
Save mikaelbr/a13b8efe37d24ef27600 to your computer and use it in GitHub Desktop.
Conceptual view switching - Avoiding imperative code in beautiful declarative markup.
<section>
<hgroup>
<h1>Hello</h1>
<h2>World!</h2>
</hgroup>
<nav>
<ul>
<li>Foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</nav>
<article>
<header>
<h1>What ever</h1>
</header>
<placeholder-view id="someId" constraint="SomeType"></placeholder-view>
</article>
</section>
<view id="view1" type="SomeType">
<div>
<p>My content here.</p>
</div>
</view>
<view id="view2" type="SomeType">
<div>
<p>Separate content here.</p>
</div>
</view>
<script>
new ViewSwitcher('#view1', {
container: '#someId',
visible: function () {
// some conditional return true | false
}
});
new ViewSwitcher('#view2', {
container: '#someId',
visible: function () {
// some conditional return true | false
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment